I experienced a memory leak in the rendering process. After a render call renderables still were refrenced by RenderableListItem s and RenderableListItem s still had references to the next.
I fixed the leak by
adding a function resetIndex to RenderableListItemPool,
editing the function freeAll in RenderableListItemPool,
and changing the calls EntityCollector performs to _renderableListItemPool instance.
Here's the changes:
RenderableListItemPool.as:
ADDED
public function resetIndex():void
{
_index = 0;
}
EDITED
public function freeAll() : void
{
var item:RenderableListItem;
while(_index-->0){
item = _pool[_index];
item.renderable = null;
item.next = null;
}
}
EntityCollector.as
[EDITED]
public function clear() : void
{
_numTriangles = _numMouseEnableds = 0;
_blendedRenderableHead = null;
_opaqueRenderableHead = null;
_renderableListItemPool.resetIndex(); // << call resetIndex instead of freeAll
if (_numLights > 0) _lights.length = _numLights = 0;
}
[EDITED]
public function cleanUp() : void
{
if (_numEntities > 0) {
for (var i : uint = 0; i < _numEntities; ++i)
_entities[i].popModelViewProjection();
_entities.length = _numEntities = 0;
_renderableListItemPool.freeAll(); // << added!
}
}
I experienced a memory leak in the rendering process. After a render call renderables still were refrenced by RenderableListItem s and RenderableListItem s still had references to the next.
I fixed the leak by adding a function resetIndex to RenderableListItemPool, editing the function freeAll in RenderableListItemPool, and changing the calls EntityCollector performs to _renderableListItemPool instance.
Here's the changes:
RenderableListItemPool.as:
ADDED public function resetIndex():void { _index = 0; }
EDITED public function freeAll() : void { var item:RenderableListItem; while(_index-->0){ item = _pool[_index]; item.renderable = null; item.next = null; } }
EntityCollector.as
[EDITED] public function clear() : void { _numTriangles = _numMouseEnableds = 0; _blendedRenderableHead = null; _opaqueRenderableHead = null; _renderableListItemPool.resetIndex(); // << call resetIndex instead of freeAll if (_numLights > 0) _lights.length = _numLights = 0; }
[EDITED] public function cleanUp() : void { if (_numEntities > 0) { for (var i : uint = 0; i < _numEntities; ++i) _entities[i].popModelViewProjection(); _entities.length = _numEntities = 0; _renderableListItemPool.freeAll(); // << added! } }
ciao, pigiuz