When I want to clean the mesh item, I will also clean the mesh’s material for memory issue.
So I use:
meshItem.material.dispose(true); // deep clean
But some time I got error like:
RangeError: Error #1125: The index -1 is out of range 31.
in away3d/materials/MaterialLibrary.as:107]
my fix is:
update the “unregisterMaterial” and “unsetName” as below
/**
* Removes a material from the library when created. Called by MaterialBase.
* @private
*/
arcane function unregisterMaterial(material : MaterialBase) : void
{
var id : int = material.uniqueId;
if( id >= 0 && id < _names.length ){ _names[id] = null; }
if( id >= 0 && id < _materials.length ){ _materials[id] = null; }
material.setUniqueId(-1);
}
/**
* Releases a material's name.
* @private
*/
arcane function unsetName(material : MaterialBase) : void
{
var id : int = material.uniqueId;
if( id >= 0 && id < _names.length ){
_names[id] = null;
delete _names[id];
}
}
also change “BasicDiffuseMethod.as”
override public function dispose(deep : Boolean) : void
{
if (_texture) {
BitmapDataTextureCache.getInstance().freeTexture(_texture, deep);
_texture = null;
}
}
and “BitmapDataTextureCache.as”
public function freeTexture(texture : Texture3DProxy, deep : Boolean = false) : void
{
_usages[texture]--;
if (_usages[texture] == 0) {
_textures[Texture3DProxy(texture).bitmapData] = null;
texture.dispose(deep);
}
}
hope this help