Jump to content
Search Community

Release memory when unload SWFs using SWFloader Loadermax

lhthai2010 test
Moderator Tag

Recommended Posts

Hi !!
I'm using loadermax to load swf, image, ... it so usefull. 

But i have a problem. I can't release memory after loaded SWF file. I can't release memory use load file SWF, it just down a little memory. 

when i use queue.emty (true, true); it just delete a lasted swf file in memory (i don't know why??). Althought i make null applicationdomain! 

 

This is my code.
I use 

var queue:LoaderMax= new LoaderMax({maxConnections:1});
queue.addEventListener(LoaderEvent.COMPLETE, TotalCompleteHandler);
queue.addEventListener(LoaderEvent.CHILD_PROGRESS, childProgressHandler);
queue.addEventListener(LoaderEvent.CHILD_COMPLETE, childCompleteHandler);
queue.addEventListener(LoaderEvent.PROGRESS, TotalProgressHandler);
queue.addEventListener(LoaderEvent.ERROR, childFailHandler);
var appDomain : ApplicationDomain = new ApplicationDomain();

I run for to load SWF

queue.append(new SWFLoader( (this.serverURL + loadConfig.elements(modul).SWFLoader[i].@url), 
{ 	name:loadConfig.elements(modul).SWFLoader[i].@name, 
	estimatedBytes:loadConfig.elements(modul).SWFLoader[i].@estimatedBytes, 
	container:this, 
	alpha:loadConfig.elements(modul).SWFLoader[i].@alpha, 
	x:loadConfig.elements(modul).SWFLoader[i].@x, 
	y:loadConfig.elements(modul).SWFLoader[i].@y, 
	width:loadConfig.elements(modul).SWFLoader[i].@width, 
	height:loadConfig.elements(modul).SWFLoader[i].@height,
	context:new LoaderContext(false, appDomain)
} ));

this is my code to unload all file in SWF:

queue.empty(true, true);
System.gc();
appDomain = null;
System.gc();

when i call Unload all file. i still see SWF files that i was loaded. (i use TheMiner to see file i loaded)

Thanks so much!!!!

Link to comment
Share on other sites

The most likely cause is something in your swf that wasn't cleaned up properly. For example, if it adds event listeners to the stage or starts NetStreams or something like that - there's no way that LoaderMax/SWFLoader can know the code that is run inside the SWF that creates dependencies/references that may prevent GC, so please make sure you clean up those things before calling queue.empty(true, true). 

Link to comment
Share on other sites

Thanks for your answer! 

 

I did it! 

 

But I release by this way (because i still don't know how i can't remove all SWF file !!! ): 

I call e.target.dispost(true); when each target download complete.

 

I just call myApplicationDomain = null; when i want to cleare memory! 

How do you think about my way? it is correct???

Thank you so much! 

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...