I’d like to know how to deallocate memory from assets that I no longer need in a particular scene. Currently, our assets textures are staying in memory after we unload the asset in a scene.
<a-scene>
<a-box src="texture.jpg"></a-box>
</a-scene>
I’d like to know how to deallocate memory from assets that I no longer need in a particular scene. Currently, our assets textures are staying in memory after we unload the asset in a scene.
<a-scene>
<a-box src="texture.jpg"></a-box>
</a-scene>
EDIT: The easiest way to dispose a texture is to grab an entity's material and call material.map.dispose()
. For example, this.el.getObject3D('mesh').material.map.dispose()
, until A-Frame can automatically handle it.
You can get the texture objects from document.querySelector('a-scene').systems.material.textureCache
and run .dispose()
on a texture.
Alternatively, I believe you can grab the texture from an entity via document.querySelector('a-entity').components.material.material.map.dispose()
.
There is an issue filed to do this automatically: https://github.com/aframevr/aframe/issues/2166