It seems that actually you donât dispose all meshes here. The same with materials etc.
Every time you dispose of a mesh scene.meshes.length gets shorter so gets to 0 before all meshes are disposed of. Use while loop.
while(scene.meshes.length {
var mesh = scene.meshes[0]
mesh.dispose();
}
There is nothing left and it becomes a blank, but only part of the memory is released. If I open / close pages frequently, I can see that the memory is obviously increasing
I made a demo without any nesting and tested it. I felt that it was a problem with the model. I changed other models and repeated loading n times. The memory can be destroyed, but if I changed back to the super large model, the memory can only be destroyed by half. But my model canât be shared. You can find a larger model and load it. This is the address of the demo without redundant code:babylonjs: babylonjs
localhost:port/ This address can load the model
localhost:port/#/test This address can trigger the method of destroying instances by switching routes
I used the browserâs memory analyzer to take a heap snapshot to see if you can analyze the occupation and destruction of memory. I put it in that project address. babylonjs: babylonjs
Under the money folder
Thatâs not 100% correct, especially since the browser makes the decisions as to when to actually garbage-collect unneeded objects. It SHOULD be true, but i wouldnât take that as the correct state.
Taking a memory snapshot (and counting the remaining/referenced objects) is the right way to go if you want to be sure if those objects were disposed.
Of course, I am not saying donât have an issue, iâm just saying there is a safer way to check
You can also start your browser with garbage-collection support turned on and call window.gc() when needed. But this is not recommended for a day-to-day usage.
I believe you have some memory leaks somewhere, but it would be better to make more extensive memory tests before, probably it would help to pinpoint the cause.
I called GC without any effect at all. I took a memory snapshot using the timeline of memory and found that there are many map, bytecodearray and promisereaction objects under the system, and the map has very deep recursion (about more than 100 layers of nodes). According to the memory analysis of the timeline, these memories have not been released. I donât know what has been done in babylonjs.
Hello, has the problem improved? Iâm a little confused about this problem and it crashes me, every time I open it, I have to close the browser and reopen the page after a few minutes, and every time I click it, it takes 3 seconds for me to drag or rotate it. I think thatâs why my model is so big.
Hard to tell without a PG or the script as @Cedric says. It can have many factors or even a combination of factors. It can be something as simple as a type error in the script (creating a loop). Or it could come from the model or it could come from an unknown bug. Itâs nearly impossible to detect just like that.