Hello, I'm trying to create a simple swf loading/unloading procedure. The swf contains a document class.
This is my current setup:
Loading code:
package projects.triveo_mobile.services.all
{
import com.greensock.loading.SWFLoader;
import flash.display.Sprite;
import flash.events.MouseEvent;
/**
* Loads other mobile services from the triveo platform into a single application
* @author Trayko Traykoff
*/
public class Test extends Sprite
{
private var _swf_loader:SWFLoader;
public function Test():void
{
//This is a stage movieclip
close_button.visible = false;
close_button.buttonMode = true;
close_button.addEventListener(MouseEvent.CLICK, onCloseButton);
//This is a stage movieclip
load_button.buttonMode = true;
load_button.addEventListener(MouseEvent.CLICK, onLoadButton);
}
private function onCloseButton(close_button_:MouseEvent) : void
{
_swf_loader.unload();
_swf_loader.dispose(true);
_swf_loader = null;
load_button.visible = true;
close_button.visible = false;
//System.pauseForGCIfCollectionImminent(0);
//System.gc();
}
private function onLoadButton(e:MouseEvent):void
{
load_button.visible = false;
close_button.visible = true;
_swf_loader = new SWFLoader('Untitled-1.swf', { name: 'room', container: this } )
_swf_loader.load();
}
}
}
And this is the swf code:
package projects.triveo_mobile
{
import flash.display.Sprite;
public class MobileMainTest extends Sprite
{
}
}
Here you can see how the memory gradually progresses when I load and unload the swf:
And after that i try to wait the garbage collection but the memory remains high:
http://prntscr.com/5l359o
I also tested this with an swf that doesn't has document class - only graphics and it also adds up apctionscript objects and overall increase in memory.
Hope you can suggest something, as this seems to be the most basic setup for loading a swf.
The leak is very small, but still exist and may build up.