How to remove material and texture without delay?

Hello everyone!

I know the function ‘.dispose()’ can remove materials, textures and meshes.

But I find that the broswer clean up the RAM at about 1 minute after the function ‘.dispose()’ is down.

So My question is how to delete them without 1 minute delay?

Thanks!

You can’t. The browser is free to release the memory whenever it wants. It shouldn’t normally be a problem, the browser will reclaim some memory if it needs to.

Thank you!

I don’t know what the scenario is for this, but if you are trying to figure out the memory usage and you don’t want to wait, you can try something like this: firefox - Is there any way to force the Javascript Garbage Collector in webkit based browsers? - Stack Overflow

thanks!

i find another problem here. when i use importmeshasync and dispose in high frequency, if the browser not cleanup the used memory in time, oom in a short time

Is there a way to detect when the memory is released by broswer on the phone?

I don’t think there’s a way.

Normally it should just work as the browser should release memory if it needs to. Maybe not everything is disposed on your side and the browser can’t reclaim the memory?

actually in my situation, I only need to release the mesh memory, the material and texture need be kept. And I use .dispose( true, false).
It this the correct usage?

Yes, that seems ok to me. However, if you are cloning meshes, the geometry will be shared by all the cloned meshes, so it won’t be released until all meshes using this geometry are disposed.

Oh the mesh i used has instances, for example, the mesh includes 10 trees( one is the root and the others are instances). If I only call .dispose for the root tree, all trees will not be released?

Calling dispose on the master mesh will also delete its instances, so you should be fine.