i have react and babylon application which is built, multiple babylonjs scenes availablein our app, when i enter and exit the scene,i am cleaning by calling engine.dispose, every time it is not cleaning all the memory it is consumed. it is holding appx 400 MB.
is they way to cleanup all the resources consumed by babylonjs
here us my scenario, i have application which hosting lot of scenes, every time host a scene i am creating the engine and scene. and every time i exit i use the engine.dispose. because GC is triggered by the browsers which will take some time. by the time user click on the another scene. it is holding up the memory, do you thing we have to reuse the engine and scene and dispose on the meshes will reduce the memory consumption. i can’t reproduce this playground this, because the it is react and babylonjs application
here is my site, please click on different scene and exit, i am memory is not reducing, when i exit
engine.dispose is synchronous, but the browser is free to release the memory later on, there’s no guarantee that it will do it just after the call. You should try to debug by making some memory snapshots using the “Memory” pane of the Chrome dev tools after you dispose of a scene and see which objects remain in memory (make sure to issue a manual garbage collect to be sure that all reclaimable objects are reclaimed! I think there’s a button that does that in the Performance tab).
in the play ground when it is initialize it is taking 447 MB in edge in my machine in which 180MB is taken web GL context.
when i click on the click me button which i am calling engine.dispose(), i assuming the 180 MB will reduce after some time, but it is not getting reduced after long time also.
If you want to monitor memory consumption, you should use the Memory pane of the Chrome dev tools or similar tools (I assume such tools do exist for Firefox too, for eg).
The memory shown in the task manager is a global value for the whole exe process and you don’t really know what it encompasses.
I instrumented the underlying gl calls and I can see that everything created is correctly released in this scene. Actually, running a create/render/dispose/ loop does not grow the memory over time.