this._scene.background = new THREE.WebGLCubeRenderTarget(
512,
{}
).fromEquirectangularTexture(this._renderer, texture);
Works fine, but later on I am dynamically changing textures for this background. At first I try to dispose it by calling:
this._scene.background.texture.dispose();
this._scene.background.dispose();
And then again fromEquirectangularTexture with the new texture.
It is working, but problem (a big one) is that background textures are not disposed. Leading to memory leaks and crashes. I can see it in renderer.info as well as in plain memory going up.
I tried variuos order of dispose call to .background and .background.texture, but no luck.
If you don’t need the texture anymore, use texture.dispose(). A related memory leak was fixed in the current dev version (see, https://github.com/mrdoob/three.js/pull/20439). The next release (r122) will contain this patch.
Can you please try if the memory leak is still present with the latest dev version of three.js using the new approach (not using fromEquirectangularTexture())? Builds are available here.