Jump to content
Search Community

library items of loaded swf stay in memory after unload

McFreaq test
Moderator Tag

Recommended Posts

Hi Guys,

 

I have a pressing issue with a flash project in which I am using LoaderMax to load swf into a main application. I don't believe this is a LoaderMax issue, rather a flash bug in general or something having to to with application domains that I don't completely understand yet.

 

Here is my test setup in which I tracked down the memory issue I'm having in the project:

 

> I load an external swf file with the SWFLoader function into an empty movieclip in my main application

> the swf file contains a jpg image positioned on stage plus 4 additional images in the library which have their export for actionscript option set to true

> the swf file does not instantiate any of these images, nor does the main application into which the swf is loaded

> when I unload the swf, some memory gets released BUT a certain amount (which is connected to the number of images in the library) stays in the system memory.

> for unloading the swf I thoroughly remove all eventListeners, use loader.unload and loader.dispose(true), remove the container movieclip from the display list, null the reference to both the loader as well as the container mc into which the swf was loaded.

 

How do I get rid of the loaded library content of the loaded swf???

Link to comment
Share on other sites

Hello again.

 

While I was not able to solve my described problem as such, I worked my way around it. That is I got rid of every possible library item in my loaded SWF files and loaded them at runtime using the corresponding LoaderMax loaders for the different media types. This was of course only possible because in this particular project I also was the author of the SWFs to load. I threw out all items heavy in file size like images and was astounded when I discovered that also using Flashs new TLF textfields ads a mere 2.5MB of ram usage every time I load and unload a SWF file containing such a textfield. Also all videos which I load, regardless of whether using my own code or the Greensock VideoLoader, account for an additional 1.5MB not removed from ram.

In the end I was able to reduce the amount of data remaining in memory after unloading by about 90%, fine for this project but still not satisfying in general.

 

If somebody however has some thoughts on how to solve the real issue of libraries in imported SWF files remaining in memory after disposal, I would be more than happy to learn more about it.

 

 

 

PS: My flash application is an offline projector running on Mac and Windows PCs. I did not test if the described memory management problem exists when running the application in a browser/ online.

Link to comment
Share on other sites

  • 1 month later...

Ive try this method:

 

_scene_MainMenu = new scene_MainMenu();

 

queue.unload(); //this is loaderMax queue

removeChild(_scene_MainMenu);

_scene_MainMenu = null;

System.gc();

 

but yet not all memory being free. any idea's?

Link to comment
Share on other sites

a huge memory free after i implement this method.

 

public function CustomEvent(type:String, data:* = null)
{
this.data= data;
super(type);
}

override public function clone():Event 
{ 
return this; 
}

private function completeHandler(event:LoaderEvent):void 
{			
var _event:Event = new CustomEvent(Event.COMPLETE);
dispatchEvent(_event);
}

_scene_xmlLoader.addEventListener(Event.COMPLETE, onAsset_scene_xmlLoader_Complete, false, 0, true);

private function onAsset_scene_xmlLoader_Complete(event:CustomEvent):void 
{
_scene_xmlLoader.removeEventListener(Event.COMPLETE, onAsset_scene_xmlLoader_Complete, false);
}

 

I suspect "override public function clone():Event " doing the trick .. Btw I love GreenSock classes :)

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