3DTilesRendererJS icon indicating copy to clipboard operation
3DTilesRendererJS copied to clipboard

Dispose not working properly

Open abaldacci opened this issue 2 years ago • 7 comments

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

abaldacci avatar Mar 24 '22 17:03 abaldacci

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"?

gkjohnson avatar Mar 25 '22 18:03 gkjohnson

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?

abaldacci avatar Mar 28 '22 07:03 abaldacci

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?

gkjohnson avatar Mar 28 '22 17:03 gkjohnson

Ok, I can take a look.

abaldacci avatar Mar 28 '22 19:03 abaldacci

Great thanks! Let me know if you have any trouble or questions and I can point you in the right direction.

gkjohnson avatar Mar 28 '22 22:03 gkjohnson

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.

gkjohnson avatar Jul 04 '22 16:07 gkjohnson

### Why does loading the simplest model cause such errors? How can I solve them?

1.zip


2022-09-16_093201

2022-09-16_094040

ailaohuyou-bj avatar Sep 16 '22 01:09 ailaohuyou-bj

Sorry for the late reply. I will test again with a more recent version of the library.

Thanks

AB

abaldacci avatar Jan 12 '23 08:01 abaldacci

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.

gkjohnson avatar Jan 12 '23 09:01 gkjohnson

Fixed with #344

gkjohnson avatar Jun 01 '23 05:06 gkjohnson