Jump to content
Search Community

Curious if my SWFLoader's unload() is working

Default test
Moderator Tag

Recommended Posts

Hello, I'm new to Greensock and it's products loving the ease of use and many of the futures the native classes just do not provide, or complicate, but i'm running into an issue...

 

I'm developing an application that continuously loads and unloads swf's. The internal swf's aren't much other than each one seperately loads a different xml file full of content and presents it on the stage. I've been running into issues of memory leaks, and my application running slow and ultimately coming to a complete stop after running for a long period of time. That is why i decided to go to loaderMax.

 

Well here's my issue, i have it running fine, but the memory is still climbing even with the new additions of loaderMax. Actually it seems to be climbing at a higher rate than it did prior to using Loader Max. I'm wondering if i'm doing something incorrect, or if there's something that i've just missed.

 

Here is a snippet of the code that loads the swf's
 

function zoomIn():void
{
	TweenLite.killTweensOf(slideArray[randomSqareNum]);
	randomSqareNum = Math.floor(Math.random() * 100 / 2);
	setChildIndex(slideArray[randomSqareNum], numChildren - 1);
	setChildIndex(curWeather_mc, numChildren - 1);
	setChildIndex(bottomContent.content, numChildren - 1);
	setChildIndex(weatherVid, numChildren - 1);
	sqrOriginalX = slideArray[randomSqareNum].x;
	sqrOriginalY = slideArray[randomSqareNum].y;
	TweenLite.to(slideArray[randomSqareNum], .75, {y:720 / 2-60, x:1152 / 2, scaleX:12.5, scaleY:5.2, ease:Circ.easeInOut, delay:.5,onComplete:loadSlideData, autoDispose:true});
}

function loadSlideData():void
{
	TweenLite.killTweensOf(slideArray[randomSqareNum]);
	curSlide = new SWFLoader("Slides/"+ slideXML.image[slideInt].@file, {x:(1150-1000)/2, y:(700-460)/2 - 30, onComplete:DisplaySlide}); 
	curSlide.load(true);
	addChild(curSlide.content);
}

function DisplaySlide(event:Event):void
{
	TweenLite.killTweensOf(slideArray[randomSqareNum]);
		
	slideLength.delay = slideXML.image[slideInt].timeDelay.@seconds*1000;
	slideLength.start();
	
	setChildIndex(curWeather_mc, numChildren - 1);
	setChildIndex(bottomContent.content, numChildren - 1);
	setChildIndex(weatherVid, numChildren - 1);
	
	slideLength.addEventListener(TimerEvent.TIMER, zoomOut,false,0,true);
}

function zoomOut(event:TimerEvent):void
{
	slideLength.removeEventListener(TimerEvent.TIMER, zoomOut);
	if(slideInt == slideXML.image.length()-1)
	{
		slideInt=0;
	}else{
		slideInt++;
	}
	slideLength.stop();
	TweenLite.to(slideArray[randomSqareNum], .75, {y:sqrOriginalY, x:sqrOriginalX, scaleX:1, scaleY:1, ease:Circ.easeInOut,onComplete:zoomIn});
	removeChild(curSlide.content);
	curSlide.unload();
	curSlide.dispose(true);
	
}

I tried doing some tracing on the loader that is being unloaded, and it states "SWFLoader 'loader1' (Myslide)", then "SWFLoader 'loader2' (Myslide)". I'm wondering if each time it's loading if it's creating a new loader every time and not fully unloading the previous.

Any help will be greatly appreciated. Also let me know if you have any questions.

 

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

Sorry to hear you're having trouble.

 

You're code looks solid and nothing jumps out at me as cause for concern. We're certainly not aware of anything inherent to LoaderMax causing memory leaks, the fact that memory leaks were evident prior to using LoaderMax gives me further reason to believe its not at fault.

 

Adobe is notorious for introducing bugs to the native Loader and plenty of times we've had to find ways to work around them. What version of Flash Player are you using? Have you tried older versions?

 

The biggest culprit for something not being garbage collected properly is if you have added your own eventListeners to the loader (outside the callbacks in the constructor) OR if the loaded swfs addEventListeners to the stage and you don't remove those. None of that is evident in your code though.

 

If there is anyway you can provide a very simple version of your files that we can use to replicate the issue we'll see what we can do. 

Link to comment
Share on other sites

Thank you for taking a look. The only code outside of these functions that relates to the loaders a global variable for each loader so i can access it in other functions. I also haven't attached any external listeners (one of the great things i love about your code)

 

You did give me an idea. I haven't tried using older versions of flashplayer. I'll do a little more tinkering and if i'm having further issues i will upload some simplified files for you.

 

Thanks for the quick reply!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...