Skip to content Skip to sidebar Skip to footer

Deallocate Object Three Js

I'm doing a project using webGl and Three.js. My problem is only one: I need to deallocate memory because, during the game, i have to create a lot of object so i don't want to allo

Solution 1:

The browser will clean up your objects for you. When you've dereferenced the objects, the browser will perform a cleanup of garbage, and all of that will be removed for you.

To test how and when this happens, you can use the Timeline tab in Chrome. After you've removed a large object, you should eventually see a "Garbage Collection" event. This indicates that the browser performed a cleanup.

As far as making that explicit, there's no way to force the browser to free a particular piece of memory. Leaning on the garbage collector is generally fine, though, as it is quite fast in modern browsers. I would be more concerned about the number of objects that you allocate, though. Especially in 3D applications, large numbers of object allocations (even for small objects) can result in quite a lot of heap churn, which could very negatively impact your rendering performance.

Post a Comment for "Deallocate Object Three Js"