Skip to content

Commit

Permalink
fix a ResourceList<> "soft" leak when destroying a material
Browse files Browse the repository at this point in the history
A ResourceList<> object was leaked when destroying a material until the 
Engine was shut down. This could however grow unbounded if churning 
through Materials.

What was actually leaked was entries in the hashmap linking a material
to its material instance list.

BUGS=[383158161]
  • Loading branch information
pixelflinger committed Dec 10, 2024
1 parent 03fdadf commit 776a748
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion filament/src/details/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,13 @@ bool FEngine::destroy(const FMaterial* ptr) {
if (!ASSERT_PRECONDITION_NON_FATAL(pos->second.empty(),
"destroying material \"%s\" but %u instances still alive",
ptr->getName().c_str(), (*pos).second.size())) {
return false;
// We return true here, because the material has been destroyed. However, this
// leaks this material's ResourceList<FMaterialInstance> until the engine
// is shut down. Note that it's still possible for the MaterialInstances to be
// destroyed manually.
return true;
}
mMaterialInstances.erase(pos);
}
}
return success;
Expand Down

0 comments on commit 776a748

Please sign in to comment.