3DTilesRendererJS
3DTilesRendererJS copied to clipboard
Dispose not working properly
Hi,
I have done some tests about using the dispose function to free up the memory used by the library.
I have a minimal (typescript) example in which I load a (large) photogrammetric dataset and press a button for disposing everything.
Depending on how I interact with the model, after calling dispose() and detaching from the scene, some resources appear to remain linked to ThreeJS.
In particular, memory appears to be released (check done using ThreeJS Stats) but renderer.info.memory.textures and renderer.info.memory.geometries have a count different from zero.
Is this a known issue? Any idea?
Thanks
Depending on how I interact with the model, after calling dispose() and detaching from the scene, some resources appear to remain linked to ThreeJS.
Can you elaborate with some more detailed repro steps? What do you mean by "depending on how I interact with the model"?
Yes, I mean depending on how much I zoom on the model and thus on how much tiles are loaded.
If the model is viewed from a distance and few tiles are loaded (for example from 2 to 20), the dispose function seems to work correctly.
As soon as I start zooming and lots of tiles are loaded (for example 100 to 200 tiles), there is the problem described above.
Are both active and non active tiles disposed automatically or one should call markAllUnused() before the dipose call?
Moreover, data which is in the download or parse queues is disposed automatically?
It seems there may be an issue related to calling "dispose" before removing the tile set from the scene or while geometry is downloading. It's not immediately clear to me where the issue is. Would you like to investigate and make a PR?
Ok, I can take a look.
Great thanks! Let me know if you have any trouble or questions and I can point you in the right direction.
I just made a small fix for disposal in #272 but I don't think it's related to what you're seeing. The demos show the texture and geometry count in three.js after dispose is called and they all go to 0 on dispose / rebuild. I'll need more of a repro to look into this any more.
Sorry for the late reply. I will test again with a more recent version of the library.
Thanks
AB
Great, thanks! There was a suggested fix for dispose in #289 for the case where recursive tilesets were but it never got completed and tested properly. You can see my recommended change here if you'd like to give that a try and test it out.
Fixed with #344