PDA

View Full Version : loading as2 files and mem usage



zworp
December 12th, 2007, 04:48 AM
I’m working on a as3 app that showing a slide show with a bunch of as2 banners.
BannerA load, is shown for x seconds, then BannerB is loaded, and so on.
The problem is that for every new banner I load the System.totalMemory is increased with 100-500kb, the old banners that I’m no longer showing seems to stay in memory and is not removed by the GC.
The slide show is looping so after a while the mem usage gets really high.

This is the function that runs when a new banners has finished loading




private function imgComplete(img:DisplayObject):void{

if(_activePromo != null){
removeChild(_activePromo);
_activePromo.mask = null;
_activePromo = null; //this doesn’t seem to remove it.
}

_activePromo = img;
addChild(_activePromo);
_activePromo.mask = _mask;

if(_promos.length > 1)
setTimeout(loadPromo, _showtime);

}



Is there any other reference to _activePromo that I need to remove?
I’ve removed the listeners to the Loader object that loads it (and then reference to the Loader itself).


thanks.