Hi there,
in my application i need to create and destroy some objects depending by user interaction with the scene.
I’ve found out that every time i destroy and then re-create the object the heap memory increase: it seems that some resources are not released properly. So the question is, what’s the best practice to do that?
This is a PG similar to my applicaton: https://playground.babylonjs.com/#TESQZM#18
Click on the ground to toggle the creation/delete of the object (at least 10 times to see some significant change in memory)
What it seems to increase are some array object as you can se from these snapshots taken form Chrome DevTools:
So, generally speaking, it is not enough to dispose only the mesh, i must always dispose each material and texture of that mesh, is ti right?
Thank you very much, now i try also in my application.
Thing is it depends cause materials and textures may be shared so you need to manage their lifetime. You can nevertheless use the dispose parameters of the mesh to handle it from the mesh