Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - run clear trackers on render world #6878

Closed
wants to merge 5 commits into from

Conversation

hymm
Copy link
Contributor

@hymm hymm commented Dec 7, 2022

Objective

Solution

  • clear_trackers was not being called on the render world. This causes the removed components vecs to continuously grow. This PR adds clear trackers to the end of RenderStage::Cleanup

Migration Guide

The call to clear_trackers in App has been moved from the schedule to App::update for the main world and calls to clear_trackers have been added for sub_apps in the same function. This was due to needing stronger guarantees. If clear_trackers isn't called on a world it can lead to memory leaks in RemovedComponents. If you were ordering systems with clear_trackers this is no longer possible.

@hymm
Copy link
Contributor Author

hymm commented Dec 7, 2022

We should probably add some docs to sub apps that they need to add clear_trackers to the sub app too or just call it for every sub app world somewhere, but not sure there's a good place for that.

@james7132 james7132 added A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times C-Bug An unexpected or incorrect behavior labels Dec 7, 2022
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 7, 2022
@mockersf
Copy link
Member

mockersf commented Dec 7, 2022

would it be better to call it here:

(sub_app.runner)(&mut self.world, &mut sub_app.app);

and add

            sub_app.app.world.clear_trackers();

@hymm
Copy link
Contributor Author

hymm commented Dec 7, 2022

That works. Last night I was a little worried what that would mean for pipelined rendering, but I can put it in the sub app run function in that pr.

https://github.com/hymm/bevy/blob/d0ea7adf36a15e9adcc78485bb595ebf188c8a16/crates/bevy_app/src/app.rs#L97-L99

@hymm hymm force-pushed the clear-trackers-on-render-world branch from a971b74 to 9b13f4d Compare December 7, 2022 21:04
@hymm
Copy link
Contributor Author

hymm commented Dec 7, 2022

Moved the call to clear_trackers into App::update.

It does bring up the question of whether I should move the call for the main world into App::update too for consistency

hymm added a commit to hymm/bevy that referenced this pull request Dec 7, 2022
@james7132
Copy link
Member

It does bring up the question of whether I should move the call for the main world into App::update too for consistency

Probably should since it's currently only found via a runtime addition to CoreStage::Last. This would make it globally consistent for all Apps, including subapps.

@hymm hymm added the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Dec 7, 2022
@james7132 james7132 added this to the 0.10 milestone Dec 10, 2022
@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Dec 11, 2022
# Objective

- Fixes #6417

## Solution

- clear_trackers was not being called on the render world. This causes the removed components vecs to continuously grow. This PR adds clear trackers to the end of RenderStage::Cleanup

## Migration Guide

The call to `clear_trackers` in `App` has been moved from the schedule to App::update for the main world and calls to `clear_trackers` have been added for sub_apps in the same function. This was due to needing stronger guarantees. If clear_trackers isn't called on a world it can lead to memory leaks in `RemovedComponents`.
@bors bors bot changed the title run clear trackers on render world [Merged by Bors] - run clear trackers on render world Dec 11, 2022
@bors bors bot closed this Dec 11, 2022
hymm added a commit to hymm/bevy that referenced this pull request Dec 12, 2022
hymm added a commit to hymm/bevy that referenced this pull request Dec 15, 2022
@hymm hymm deleted the clear-trackers-on-render-world branch December 21, 2022 23:44
@james7132 james7132 mentioned this pull request Jan 6, 2023
alradish pushed a commit to alradish/bevy that referenced this pull request Jan 22, 2023
# Objective

- Fixes bevyengine#6417

## Solution

- clear_trackers was not being called on the render world. This causes the removed components vecs to continuously grow. This PR adds clear trackers to the end of RenderStage::Cleanup

## Migration Guide

The call to `clear_trackers` in `App` has been moved from the schedule to App::update for the main world and calls to `clear_trackers` have been added for sub_apps in the same function. This was due to needing stronger guarantees. If clear_trackers isn't called on a world it can lead to memory leaks in `RemovedComponents`.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- Fixes bevyengine#6417

## Solution

- clear_trackers was not being called on the render world. This causes the removed components vecs to continuously grow. This PR adds clear trackers to the end of RenderStage::Cleanup

## Migration Guide

The call to `clear_trackers` in `App` has been moved from the schedule to App::update for the main world and calls to `clear_trackers` have been added for sub_apps in the same function. This was due to needing stronger guarantees. If clear_trackers isn't called on a world it can lead to memory leaks in `RemovedComponents`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory usage of camera bundles
5 participants