react-three-renderer icon indicating copy to clipboard operation
react-three-renderer copied to clipboard

Are textures deallocated when removed from render tree?

Open nickpolet opened this issue 7 years ago • 1 comments

I have a project that involves dynamically loading lots of textures into a scene when needed. I am slightly worried that loaded textures will not be deallocated with renderer.deallocateTexture( texture ) when the mesh and material is not in the render tree.

Is this something that I will have to do manually, with something like:

this.refs.renderer.deallocate(this.refs.texture)

before the mesh and texture is removed from the scene? This could be done in the componentWillUnmount function which is actually quite a tidy place to have it.

Just thought I'd check before powering on and implementing it.

Thanks.

nickpolet avatar Apr 08 '17 12:04 nickpolet

When a texture gets unmounted it does call .dispose which I'm hoping should trigger the deallocation, but I'll try to dig deeper , run some tests with breakpoints and confirm how it exactly works and if the deallocations happen properly.

toxicFork avatar Apr 15 '17 14:04 toxicFork