Jump to content
Search Community

ActionScript Objects count increasing when loading and unloading swf

carnophage test
Moderator Tag

Recommended Posts

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:

ZL8ZzeM.png

 

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.

  • Like 1
Link to comment
Share on other sites

Hi

 

I'm having trouble deciphering what part of those images show where a memory leak exists. Everything seems relatively flat. 

I would expect one of the charts to clearly show a rise in memory usage over time. 

 

Can you explain where I should be looking to see the rise in memory usage?

Link to comment
Share on other sites

The rise is very small - only few more kb in memory than the start, but there is still some rising. I was expecting no change in kb in memory before loading and after unloading. For example the starting memory is 5000kb and at the end it's 5070kb.

 

Here i drew a horizontal red line, you can see how the memory is above the line at the end:

red.png

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