-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Remove InstanceId
when Scene Despawn
#12778
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
Fixes one leak. We still leak in |
If calling |
It shouldn't. |
Additionally, if the user calls |
Then just remove the instance from |
if let Some(&SceneInstance(scene_instance)) = world.get::<SceneInstance>(entity) { | ||
let Some(mut scene_spawner) = world.get_resource_mut::<SceneSpawner>() else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extremely minor nit, but is there a reason that one of these is if let
and the other one is let ... else
, instead of both being let ... else
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like using let ... else
consistently would be better. The reason for the inconsistency between the two is that in a later commit, I changed resource_mut
to get_resource_mut
, but I didn't notice that the if let
expression needed to correspond to it.
# Objective - Fix #12746 - When users despawn a scene, the `InstanceId` within `spawned_scenes` and `spawned_dynamic_scenes` is not removed, causing a potential memory leak ## Solution - `spawned_scenes` field was never used, and I removed it - Add a component remove hook for `Handle<DynamicScene>`, and when the `Handle<DynamicScene>` component is removed, delete the corresponding `InstanceId` from `spawned_dynamic_scenes`
removing from the 0.13.2 milestone as this use components hooks from #10756 which are not available in the 0.13 |
Objective
InstanceId
withinspawned_scenes
andspawned_dynamic_scenes
is not removed, causing a potential memory leakSolution
spawned_scenes
field was never used, and I removed itHandle<DynamicScene>
, and when theHandle<DynamicScene>
component is removed, delete the correspondingInstanceId
fromspawned_dynamic_scenes