Memory Leak is happening

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

I think we would need a repro to help on the matter.

you can see here our app, when get it and out of the scene, i am calling dispose, but it is not clean all the memory it was created

Are you clearing/nulling all global references you create?
otherwise i don’t think GC will clean it

i am calling Engine.Dispose

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

@aWeirdo @Evgeni_Popov

is engine.dispose() releases all the objects. is it sync or async ? is there a callback to check where all the objects are disposed.

i have engine.dispose() but there is some memory is holding.

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).

Would be amazing if you could repro on a smaller sample in the playground ???

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.

screen shot of the memory is in attachment.

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.