Memory Leak

Sorry, I’m a newb and posted this previously in the wrong section…

Hey, I know there are other posts on here about this problem, but I can’t seem to figure out why this isn’t working. This is a test code I wrote that is suppose to imitate a slideshow. The problem is each cycle of the code uses more memory and I don’t understand how to remove my object from memory.


import fl.transitions.*;
import fl.transitions.easing.*;
var swfLoader:Loader = new Loader;


var curPic:MovieClip = null;
var picTimer:Timer = new Timer(3000);

slideshow();

function slideshow ():void
{
    var mem:String = 'Before ' + Number( System.totalMemory / 1024 / 1024 ).toFixed( 2 ) + 'Mb';
    trace( mem );
    
    //trace("Slideshow");
    swfLoader = new Loader;
    swfLoader.load(new URLRequest("christianPic1.swf"));
    swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, picLoaded, false, 0, true)
}

function picLoaded (E:Event):void
{
    //trace("PicLoaded");
    swfLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, picLoaded);
    curPic = E.target.content;
    container.addChild(curPic);
    
    picTimer.start();
    picTimer.addEventListener(TimerEvent.TIMER, nextPic, false, 0, true);    
}

function nextPic (TE:TimerEvent):void
{
    //trace("nextPic");
    picTimer.stop();
    picTimer.removeEventListener(TimerEvent.TIMER, nextPic);
    
    container.removeChild(curPic);
    curPic = null;    
    
    var mem:String = 'After '  + Number( System.totalMemory / 1024 / 1024 ).toFixed( 2 ) + 'Mb';
    trace( mem );
    
    slideshow();
}