Avg. Rating 1.0

Problem

Memory leaks have been observed in the FL2.x players on devices.

Solution

If you find that your application is leaking memory then try replacing movies and re-using existing objects. This causes the player to forcefully recover the memory.

Detailed explanation

unloadMovie There is a known memory leak with the unloadMovie function observed in the Flash Lite 2.x players.  This is also a useful tactic when building image gallery style applications, always re-use the movie clips.

There are other ways to unload movieclips by using the standard APIs, here we look at solving the memory leak problem above.

  • Create a simple SWF with a holder movieclip eg “currentWidget_mc”  
  • Load your initial SWF into this holder movieclip
  • Load your next SWF into “currentWidget_mc” and using the same depth parameter; effectively replace it
loadMovie( " url ", level ) 
or 
var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth()); // only called once!
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip("YourImage.jpg", container);

function onLoadInit(mc:MovieClip) {
    trace("onLoadInit: " + mc);
}
The suggestion here is that instead of unloading, by simply “replacing” a movieclip the previous movie will be forcefully removed.  

 


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes