Skip to content
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

Closed
3 of 13 tasks
Mavhod opened this issue Aug 19, 2017 · 10 comments
Closed
3 of 13 tasks

Clear scene but memory is not removed. #11984

Mavhod opened this issue Aug 19, 2017 · 10 comments

Comments

@Mavhod
Copy link

Mavhod commented Aug 19, 2017

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 at src/renderers/webgl/WebGLRenderLists.js and so I add code renderer.dispose() memory is cleared, but I not want to destroy the renderer.

Three.js version
  • Dev
  • r87
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, ...)
@WestLangley
Copy link
Collaborator

Can you demonstrate the issue with a simple, live example?

@Mavhod
Copy link
Author

Mavhod commented Aug 19, 2017

Ok, I write sample here:

http://jsfiddle.net/akmcv7Lh/177/

@aardgoose
Copy link
Contributor

Have you tried

renderer.renderLists.dispose();

Which removes all the renderers references to renderItems?

( I hit this problem which is why renderLists is now exposed, although this was before r86)

@Mavhod
Copy link
Author

Mavhod commented Aug 21, 2017

Yes, renderer.renderLists.dispose(); is will remove memory,

But should I use this?, because document says: renderLists used internally.

@jchen10
Copy link

jchen10 commented Aug 21, 2017

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.
#11996

@aardgoose
Copy link
Contributor

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

@jchen10
Copy link

jchen10 commented Aug 21, 2017

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.

@Mavhod Mavhod closed this as completed Aug 21, 2017
@aardgoose
Copy link
Contributor

@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.

@jchen10
Copy link

jchen10 commented Aug 22, 2017

@aardgoose Thanks much for your clarification.

@lowright

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants