# Frequently Dispose AssetContainer Causes Memory Leak

**URL:** <https://forum.babylonjs.com/t/frequently-dispose-assetcontainer-causes-memory-leak/28563>\
**Category:** Bugs\
**Tags:** gltf, performance\
**Created:** [March 19, 2022, 8:30am UTC](https://forum.babylonjs.com/t/frequently-dispose-assetcontainer-causes-memory-leak/28563 "2022-03-19T08:30:20Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![RavenLee](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@RavenLee](https://forum.babylonjs.com/u/RavenLee)\
**Post date:** [March 21, 2022, 2:07am UTC](https://forum.babylonjs.com/t/frequently-dispose-assetcontainer-causes-memory-leak/28563/3 "2022-03-21T02:07:02Z")

</div>

Hi sebavan,

Thank you for your reply. Sure it may take longer than 100ms since it is a async function. I tried 1000ms which loading process can be finished and it got slower increase.

I found this one may relate to this issue:

> [@I discovered the worst and most insidious memory leak in BabylonJS history](https://forum.babylonjs.com/t/i-discovered-the-worst-and-most-insidious-memory-leak-in-babylonjs-history/21170):
>
> In my BabylonJS project, I used the queryObjects(Promise) command and found that several thousand Promise objects were leaking memory.As shown in the figure below. I tried to analyze the memory leak Promise objects. I guessed it was GLTF loading module, so I tried to modify the source code of the module, and it worked.The culprit from GLTFFileLoader. prototype. loadAssetContainerAsync, here is my modified code. GLTFFileLoader.prototype.loadAssetContainerAsync = function …

Other observations:

1. If I use scene.onDisposeObservable.clear() after disposing assetContainer, the empty assetcontainer class will be cleaned.  
 ![企业微信截图_16477631461401](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/6/16bd005ceead5f1b3362a5125b8f601178601f60.png)
2. using chained Promise and returns Promise(assetcontainer) causes faster memory increase than just return the assetcontainer itself.

---

_[View the full topic](https://forum.babylonjs.com/t/frequently-dispose-assetcontainer-causes-memory-leak/28563)._
