Jump to content


Loader instance is not disposed

Recommended Posts



I use LoaderMax to load images from the set of urls. The problem is I can't get rid off flash.display.Loader instances. Garbage collector doesn't clean these objects at all. I checked it in flashdevelop SWF profiler.


var urls:Array = [url1, url2, url3];
mainLoader = new LoaderMax({autoLoad:true);

for(var i:int = 0; i < urls.lenght; i++)
var imgLoader:ImageLoader = new ImageLoader(urls[i], {container:someSprite, autoDispose:true});


My first thought was that I should use dispose(true) to unload the content of loader, but that did't help. ImageLoaders are cleaned, but not flash.display.Loader. Thank you.

Link to comment
Share on other sites

There was a typo in your code - you were missing a "}" after "{autoLoad:true" but I assume that was just here in the forums.


Anyway, here are some thoughts:

  1. When you set autoDispose, that only disposes of the ImageLoader instance itself, not its content (that's very intentional). If you want to dispose of the loader and its content, you are correct in assuming you should call dispose(true).
  2. Are you only using ImageLoaders or are you using SWFLoaders somewhere? I ask because if you subload a swf that has code in it that does something like adds an event listener to the stage or runs a NetStream or sound or something, that can prevent it from becoming eligible for gc (and LoaderMax cannot force that - you need to clean up after yourself by removing event listeners, closing NetStreams, etc.)
  3. I've heard of there being problems with some profiling tools where they incorrectly report instances not getting gc'd. Have you tried a different profiler or a different machine? Just curious.

If you're still having trouble, feel free to post a very simple FLA here that we can publish to see the issue clearly demonstrated. No need to post your production files - just something isolated and simplified.

Link to comment
Share on other sites

I checked my code again and some loaders aren't disposed because I didn't use dispose(true) on every single loader. But I wonder what if i want to dispose all instances connected with greensock classes (including flash.display.Loader) and leave loaded content? I think there should be some options to do that. Now, I need somehow copy the content and unload loaders.

Link to comment
Share on other sites

I'm curious about why you're concerned about getting rid of the Loader instances. I can't imagine they take up much memory at all and they're necessary to keep around if you keep the SWFLoader or ImageLoader because you might call load() on them again after changing the URL or something. See what I mean?

Link to comment
Share on other sites

You're totally right it doesn't take so much memory, but I just wanted to know if i can just leave content when I'm 100% sure I don't need to reload anything. Thank you.

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.