I know there's a lot written about the Garbage Collection, and removing assets 
in AS3...
I'm trying to get my hands around it, but I'm still strugling ;)

A simple example:

I'm adding a MovieClip from the library, and I'm removing it as well, like a 
toggle.
The MovieClip contains the System.totalMemory property.
If I keep toggling the MC on and of... the memory keeps going up...
I'm destroying the MC and removing it from the displayList...
But it's not cleared from the memory. What Am I missing?

ToggleCode:

private function toggleDebug() :void
{
            var dw:debugWindow_lib = getChildByName('debugWindow') as 
debugWindow_lib;
            if (dw == null )
            {
                        var debugWindow:MovieClip = new debugWindow_lib();
                        debugWindow.name = "debugWindow";
                        addChild(debugWindow);
            }
            else
            {
                        dw.destroy();
                        removeChild(dw);
            }
}

Class

public class debugWindow_lib extends MovieClip
{
            public function debugWindow_lib()
            {
                        addEventListener(Event.ENTER_FRAME, onEnterFrame, 
false, 0, true);
            }

            private function onEnterFrame( e :Event ) :void
            {
                        var tM:Number = System.totalMemory / 1024;
                        totalMemory.text = tM.toString();
            }
            public function destroy()
            {
                        removeEventListener(Event.ENTER_FRAME, onEnterFrame);
            }
}

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to