I found this issue when I load glb file by using LoadAssetContainerAsync.
My repro method has three steps:
set a timer to execute loadAssetContainerAsync every 100ms
call addAllToScene() in its callback function.
dispose() after addAllToScene()
The snapshot shows that the numbers of arraybuffer, objects and array increases gradually. It seems to have GC process during the process, but the overall numbers keeps growing.
I also using a webkit profiling tool to check the trend on my iphone12, it looks like the following graph.
Both physical memory and memory go up stably like going upstairs and the avaliable memory drops.
You are not waiting for one load being over to start the new one so if they take more than 100ms You will have a lot in parallel, @bghgary tried this successfully not long ago IIRC ?
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:
Other observations:
If I use scene.onDisposeObservable.clear() after disposing assetContainer, the empty assetcontainer class will be cleaned.
Sure I will put the code in zip file on the playground. While for the repro in zip file (above one) I load the glb file locally, but on playground I may use a remote one, which may introduce the request time and network problem. So I wonder if there is some approach load the glb in playground locally?
Thank you for your cencern for this issue. I am struggling with providing a proper online repro on this issue. While fortunnately I found some clues, if you have a look at the zip file and run it by a local server. if I QueryObject(AssetContainer) there are some AssetContainer empty left.
If I track the onDisposeObservable, there are many of them in the stack. when disposing the assetContainer, removing onDisposeObservable helps, but I cannot figure them all.
And looking at the code, I noticed there’s both a call to addAllToScene AND instantiateModelsToScene, the second of which DOES duplicate the skeletons, as per documentation: AssetContainer | Babylon.js Documentation (babylonjs.com). After properly disposing of these skeletons by using the returned skeletons property returned by instantiateModelsToScene, the memory usage doesn’t grow anymore.