fix(scene-manager): dispose GPU resources on event switch#783
Merged
EdwardMoyse merged 1 commit intoHSF:mainfrom Jan 24, 2026
Merged
Conversation
Signed-off-by: goyalpalak18 <goyalpalak1806@gmail.com>
Contributor
Author
|
Hi @EdwardMoyse @9inpachi , I’ve noticed the display can become unstable or crash after switching through multiple events—this is due to GPU memory not being released by Three.js automatically. I’ve implemented a recursive disposal helper in SceneManager to explicitly free up geometries, materials, and textures. I've verified the fix with the Performance Monitor; VRAM now stays stable instead of climbing linearly. Ready for a review when you have a moment! |
Collaborator
|
Thank you very much! |
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
This PR addresses a critical memory leak that occurs when switching between events or clearing event data.
While the current implementation of
clearEventData()successfully removes objects from the Three.js scene graph, it doesn't notify the WebGL renderer that the underlying GPU resources (geometries, materials, and textures) are no longer needed. In Three.js, these resources are not tracked by the JavaScript Garbage Collector and must be disposed of explicitly to free up VRAM.Without this fix, every event switch causes a linear increase in GPU memory usage. For users browsing through large ATLAS/CMS events or running the display for extended periods, this inevitably leads to a WebGL context loss or a total browser tab crash.
Changes
clearEventData: Now ensures that every object is thoroughly "cleaned" before being detached from the scene.disposeObject3Dhelper:Object3Dhierarchy..dispose()on allBufferGeometryinstances.Materialdisposal (including support forMaterial[]arrays).How to verify
clearEventData()call.Impact