-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Clear scene but memory is not removed. #11984
Comments
Can you demonstrate the issue with a simple, live example? |
Ok, I write sample here: |
Have you tried
Which removes all the renderers references to renderItems? ( I hit this problem which is why renderLists is now exposed, although this was before r86) |
Yes, But should I use this?, because document says: |
Per my investigation, the cause is that the removed items don't get cleared timely in 'renderItems'. I've made an attempting PR to fix it. |
It's OK to use renderLists.dispose() , I exposed it for this purpose. It doesn't destroy any state that can't be reestablished from your scene(s) and camera object(s) as required. see #11497 |
I am okay with renderLists.dispose(). Meanwhile I also think It's a good practice to release any unused object as soon as possible. So my PR still makes sense. |
@jchen10 As I said, RenderLists act as caches of RenderItems. RenderList.init() is called for each render list every frame, that is 60 times a second. With your PR, new RenderItems are allocated each frame and old RenderItems discarded, this creates heap pressure and more frequent garbage collections resulting in less smooth animation/rendering. You will see this in browser profiles, especially for scenes with large number of objects. This is why init() doesn't zero the internal array. |
@aardgoose Thanks much for your clarification. |
I updated to r87 recently, in r86 I dispose and remove all from the scene after clear garbage memory is clear but in r87 is not.
I check in memory debug on firefox browser found it remain in
renderItems
atsrc/renderers/webgl/WebGLRenderLists.js
and so I add coderenderer.dispose()
memory is cleared, but I not want to destroy the renderer.Three.js version
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)
The text was updated successfully, but these errors were encountered: