Skip to content

Commit 6eaa6a6

Browse files
authored
Revert attempt to fix memory leak (#18845)
This reverts commit a9b0b4e.
1 parent f3f6cad commit 6eaa6a6

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

crates/bevy_render/src/render_asset.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ pub(crate) fn extract_render_asset<A: RenderAsset>(
246246
let mut modified = <HashSet<_>>::default();
247247

248248
for event in events.read() {
249+
#[expect(
250+
clippy::match_same_arms,
251+
reason = "LoadedWithDependencies is marked as a TODO, so it's likely this will no longer lint soon."
252+
)]
249253
match event {
250254
AssetEvent::Added { id } => {
251255
needs_extracting.insert(*id);
@@ -254,20 +258,9 @@ pub(crate) fn extract_render_asset<A: RenderAsset>(
254258
needs_extracting.insert(*id);
255259
modified.insert(*id);
256260
}
257-
AssetEvent::Removed { id, .. } => {
258-
// Normally, we consider an asset removed from the render world only
259-
// when it's final handle is dropped triggering an `AssetEvent::Unused`
260-
// event. However, removal without unused can happen when the asset
261-
// is explicitly removed from the asset server and re-added by the user.
262-
// We mark the asset as modified in this case to ensure that
263-
// any necessary render world bookkeeping still runs.
264-
265-
// TODO: consider removing this check and just emitting Unused after
266-
// Removed to ensure that the asset is always "really" removed from the
267-
// render world when the last strong handle is dropped.
268-
if !removed.contains(id) {
269-
modified.insert(*id);
270-
}
261+
AssetEvent::Removed { .. } => {
262+
// We don't care that the asset was removed from Assets<T> in the main world.
263+
// An asset is only removed from RenderAssets<T> when its last handle is dropped (AssetEvent::Unused).
271264
}
272265
AssetEvent::Unused { id } => {
273266
needs_extracting.remove(id);

0 commit comments

Comments
 (0)