Memory leak with tr .js and many shapes

I created code that eats memory very quickly and dies.

I shortened this to sections for creating / deleting a code torus. I checked that the length of the scene array and the torus array shorten as the shapes are deleted, so they look well-managed, but I'm not sure where the memory leak is.

Any ideas?

http://jsfiddle.net/eVwP3/

+3
javascript memory-leaks
source share
1 answer

In webGLRenderer after deleting the grid with

 scene.remove( mesh ); 

you can free memory with

 mesh.dispose(); geometry.dispose(); material.dispose(); texture.dispose(); 

See http://threejs.org/examples/webgl_test_memory.html and http://threejs.org/examples/webgl_test_memory2.html .

EDIT: Updated to three. js r.69

PS Good demonstration. You might want to create a pool of objects and reuse them, rather than constantly allocating and freeing them.

+10
source share

All Articles