alexvoz / as3isolib

Automatically exported from code.google.com/p/as3isolib
0 stars 0 forks source link

Memory leak in IsoScene.removeChild #35

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. call removeChild
2. look in Flex profiler to see what instance stick around

What's happening is when you call addChild it adds this listener:

child.addEventListener(IsoEvent.INVALIDATE, child_invalidateHandler);

which when called does this:

invalidatedChildrenArray.push(child);

The problem is that when you call IsoScene.removeChild it doesn't remove child 
from the invalidatedChildrenArray. Here's a solution that fixes it, replace 
IsoScene.removeChildByID(id:String) with this:

        override public function removeChildByID (id:String):INode
        {
            var child:INode = super.removeChildByID(id);
            if (child)
            {
                child.removeEventListener(IsoEvent.INVALIDATE, child_invalidateHandler);

                if (invalidatedChildrenArray) {
                    for (var i:int = 0; i < invalidatedChildrenArray.length; i++) {
                        if (invalidatedChildrenArray[i] == child) {
                            invalidatedChildrenArray.splice(i, 1);
                            break;
                        }
                    }
                }
                bIsInvalidated = true;
            }

            return child;
        }

Original issue reported on code.google.com by bedroom...@gmail.com on 23 Mar 2011 at 4:46