内存泄漏有three.js和许多形状 [英] Memory leak with three.js and many shapes
问题描述
我已经创建了一些很快就会耗尽内存并死掉的代码。
我已将其削减到代码的圆环生成/删除部分。我已经检查过场景数组和我的圆环阵列的长度随着形状的移除而缩小,因此它们看起来管理得很好,但我不确定内存在哪里泄漏。
任何想法?
http:// jsfiddle。 net / eVwP3 /
在 webGLRenderer
之后删除网格
scene.remove(mesh);
你可以用
$ b <$ p来释放内存$ p>
mesh.dispose();
geometry.dispose();
material.dispose();
texture.dispose();
参见 http://threejs.org/examples/webgl_test_memory.html 和 http: //threejs.org/examples/webgl_test_memory2.html 。
编辑:更新为three.js r.69
PS很好的演示。您可能需要考虑创建一个对象池并重用它们,而不是不断地分配和取消分配。
I have created some code which very quickly eats up memory and dies.
I have whittled this down to the torus generation / removal sections of the code. I have checked that the length of the scene array and my torus array are shrunk as shapes are removed so they appear to be well managed, but I am not sure where the memory is leaking.
Any ideas?
In webGLRenderer
, after removing a mesh with
scene.remove( mesh );
you can deallocate the 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
P.S. Nice demo. You might want to consider creating a pool of objects and reusing them, rather than continually allocating and deallocating.
这篇关于内存泄漏有three.js和许多形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!