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

Ability to clean memory of static geometries #9985

Closed
3 of 12 tasks
YousefED opened this issue Nov 1, 2016 · 2 comments
Closed
3 of 12 tasks

Ability to clean memory of static geometries #9985

YousefED opened this issue Nov 1, 2016 · 2 comments

Comments

@YousefED
Copy link

YousefED commented Nov 1, 2016

Description of the problem

I'm using multiple PlaneBufferGeometry objects. I noticed when creating 10 + meshes based on this, with 255x255 segments, the memory usage can quickly jump to 100mb+.

The memory in use is mainly composed by the .array attribute in the various BufferAttributes. When running:

mesh.geometry.getAttribute("position").array = [];
mesh.geometry.getAttribute("normal").array = [];
mesh.geometry.getAttribute("uv").array = [];

For all meshes, everything still renders fine (and I can freely rotate, etc.). Memory in use drops back to 10mb. I have no intention of altering the geometries after initializing. It feels like a hack though;

  • Is there a recommended way of freeing javascript memory after the attributes have been allocated in webgl?
  • Does my workaround have any downsides? Am I missing something important here?
Three.js version
  • Dev
  • r82
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • Linux
  • Android
  • IOS
Hardware Requirements (graphics card, VR Device, ...)
@aardgoose
Copy link
Contributor

Hi,

I came across similar issues. see #9512 ... nice to see someone with the same issues, saved a lot of heap exhaustion and crashes for me,

Your solution works more by luck (the renderer defaults to Float32), and some of the mods iv'e made since I put in that PR (not accepted). The PR #9972 would remove the luck element.

The above PR puts the removal of the large arrays in a call back so there is certainty that the buffer has been uploaded. I can imagine situations where an object is out of visibility and not passed to the GPU when you expect it to be otherwise.

@mrdoob
Copy link
Owner

mrdoob commented Nov 5, 2016

#9512 and #9972 has been merged. You should be able to do this now:

attribute.onUpload( function () {

    this.array = null;

} );

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

3 participants