fix(import-manager): dispose intermediate geometries after GLTF merge#794
Open
goyalpalak18 wants to merge 1 commit intoHSF:mainfrom
Open
fix(import-manager): dispose intermediate geometries after GLTF merge#794goyalpalak18 wants to merge 1 commit intoHSF:mainfrom
goyalpalak18 wants to merge 1 commit intoHSF:mainfrom
Conversation
Signed-off-by: goyalpalak18 <goyalpalak1806@gmail.com>
Contributor
Author
|
Hey @EdwardMoyse! I fixed the memory leak by cleaning up those intermediate geometries. Ready for a review when you have a moment! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I identified a GPU memory leak in the
loadGLTFGeometryInternalfunction withinimport-manager.ts.When loading detector geometries, we clone the individual meshes to merge them into a single buffer. However, I noticed that we weren't disposing of those intermediate clones. In three.js,
.clone()allocates new GPU buffers that persist until they are manually disposed, even if the JavaScript objects are garbage collected.This was causing significant video memory accumulation—around 50-150MB per ATLAS load—which eventually led to browser crashes or black screens if a user switched between experiments multiple times in one session.
Fix
I updated the loading logic to manually dispose of all the intermediate cloned geometries immediately after they are merged into the final mesh.
This ensures that we only keep the final result in GPU memory and properly free up the temporary buffers. This change also brings
import-manager.tsin line with the disposal patterns we already use in other parts of the codebase, likephoenix-objects.ts.Impact
Test Plan