Completely removing swf file from memory

Hi All,

I’m running into an annoying issue. I have a swf file that loads another swf file (i don’t know what that swf file is going to be, it comes from whatever URL i provide and I just load it). I notice in my Activity Monitor my memory of my flash plugin in FF and Chrome increase significantly when the swf file is loaded, when I’m done with the .swf file I remove it, but the memory is somehow still allocated (it’s like it never gets removed from memory). I attempt to unload the loader that is responsible for loading the swf (shown below)

myLoader.unload();
myLoader.unloadAndStop(true);	
removeChild(myLoader);
myLoader = null;

But that doesn’t seem to do it for me. In some cases, I then have to load another swf file at some point and the memory increases again (and again with each swf being loaded). The memory seems to never free up. It just keeps increasing until the FF or Chrome plugin finally crashes. Can it’s my understanding that this is the way to remove a swf file, is there something I’m missing? The references that I looked up were:

Which sound like similar issues, but those threads were never responded to. Your help is so much appreciated!

Hey flashdaddy,

The great danger of loading other SWFs is that you’ll lose control of them. Adobe never devised a perfect way of controlling the effects of loading another SWF, so you have to be judicious with what other SWFs you load.

I don’t think there’s a great way for you to solve this problem, given that you’re not willing to impose any restrictions upon the SWFs that you’re loading. Of course, it’d be helpful if you provided examples of the troublesome SWFs; it’s always easier to deal with concrete examples.

The important thing to understand with loading external SWFs is that you’re granting a lot of authority by doing so. This is similar to how it’s potentially dangerous to load an external JavaScript file onto your site. There are sandbox rules, but they’re not particularly strict. The vetting is an important component of letting anyone use your own code as a conduit. Flash isn’t really built to subdue your own choices of what code to load.


On the other hand, if you can load the SWF bytes from a domain over which you have control, then you don’t have to care about any of the nonsense up to which those SWFs might get. You can use the powers of static analysis to sandbox any external dependencies, but only if you’re willing to host that data yourself. Flash Player will only give you control over data in your provenance.

Thanks for the response. I’m more interested in just removing the swf “the right way”. Fortunately the swf files that I’m loading aren’t really problematic, I just think I’m not removing them correctly from my project using the methods shown above. I think there is a footprint being left in the memory because I see the file size increase and when I remove it it, I see it decrease a little, but not a lot. Then when it loads again, it increases again and so forth (for each load, it steadily stays on an upward trend of memory usage even though it goes down a little when it’s removed).