AssetContainer memory leak?

The test method is to click on the scene.
confirm to this problem check this PG
This is an extreme test for the frequent import and dispose
Using the two models repeatedly, the memory increases and eventually leads to a leak.

and this PG2
13 or more models are repeatedly run under the same conditions, but the moment the same model is returned, the memory is normalized.
In both cases the memory leak occurs because my project uses them.

I’m not using instantiateModelsToScene in my project because of two things in this logic.
1 : Because it is a test environment, it has become a structure to load the same model by performing upgrade and downgrade tests.
2 : It is the same model, but the file has a different format, so it is not used as a duplicate model.
so If the cause of this is frequent importing of the same model, it can be solved with logic, but if it is a general assetsContainer dispose problem, you need to check.

Shadow cases also occur.
When shadows are set in my project the memory increases exponentially.
However, the memory leak is in better condition when no shadows are set, and the increment is negligible.

It’s funny because I recently experienced a very similar issue with the assetManager. I wasn’t using containers but else my method was pretty much the same (using an async function to pass the url and file), disposing of the mesh before adding a new task. The result I got was a dramatic loss of framerate although the model was disposed (and as I said didn’t even use containers).

I wanted to make a PG but left this aside for now, switched to another method suitable for my project without using the assetManager and have no memory leaks and much lower impact on performance while importing the asset.

I will still want to use this method (with containers this time) for loading sets of textures. I fear I will face the same problem. Will be back on it later this week.

1 Like

I found the culprits… I ll have some fixes for tomorrow evening the current list is:

  • morphTargetManagers are leaking from assetContainer when loaded from GLTF
  • running animations are leaking when removing from the scene
  • some latest changes to our observables are creating new retention sites

I ll address all of them for tomorrow evening


should be fixed by Leak Fix by sebavan · Pull Request #13616 · BabylonJS/Babylon.js · GitHub


I checked that is merged and also checked the corresponding case in PGs

so, i install npm of last version babylon cores … etc (5.50.1) in my local project
but still to occur memory leak Have you not updated this version yet?

The fix has only been merged now, it will be in the next version.