Freeing memory with trjs

I have a problem with freeing up memory three times, when I delete the grid using scene.remove (mesh), the mesh is deleted, but it seems that the memory used from js is not freed.

I am using webglrenderer with buffering for grid and windows.

+1
source share
2 answers

This may be the dark side of js memory usage.

First try setting a primitive value for your objects.

mesh.geometry.dispose();
mesh.geometry = null; // or undefined .
//also cool
delete mesh.geometry 

Another way (try hacking):

 mesh.geometry = VerySmallmesh.geometry  //see for three.js how to do this if this is not correct mesh.geometry = null; 
// try to override memory stack 

You must be sure that this object is only an instance of itself (how to say). Make sure you don’t have a clone, if you have what you need to destroy it.

: , slice forEach .

+4

. , , . , . .

if (mesh) {
    scene.remove(mesh);
    mesh.geometry.dispose();
    mesh.material.dispose();                                    
    mesh = [];
}

, StackOverflow . three.js

0

All Articles