Solved

Flash as 3.0 Loader Memory extending

Posted on 2009-03-31
7
291 Views
Last Modified: 2013-11-11
Hi, I have a main file with a loader+ 2 buttons in it which loads & unloads 2 external ".swf" files and a trace to monitor the System.totalMemory. PROBLEM IS after  my unload command the memory dosnot get's free and even increasing on every load then unload command.

var loaderObj:Loader

var sp:Sprite= new Sprite()

 

function mcLoad(e:MouseEvent){	

	loaderObj= new Loader();

	loaderObj.name='tension';

 	var str:String="i.jpeg";

	loaderObj.load(new URLRequest(str));

	sp.addChild(loaderObj);

	stage.addChild(sp)

}

 

function mcUnload(e:MouseEvent){

	loaderObj.unload();

	sp.removeChild(loaderObj);

	stage.removeChild(sp)

	trace(System.totalMemory);

}

 

b0.addEventListener(MouseEvent.CLICK,mcLoad);

b1.addEventListener(MouseEvent.CLICK,mcUnload);

Open in new window

0
Comment
Question by:aditkohli
  • 2
7 Comments
 
LVL 9

Accepted Solution

by:
asaivan earned 168 total points
ID: 24061591
try setting sp to null, after you've removed it from the stage.

e.g.

sp = null;
0
 

Expert Comment

by:bridgetimiller
ID: 24064124
Try using Loader.unloadAndStop().  This is allow help clear all references to the Loader and make it accessible for garbage collection.
0
 

Assisted Solution

by:bridgetimiller
bridgetimiller earned 166 total points
ID: 24064133
loaderOjb.unloadAndStop() in your case. :)
0
 
LVL 39

Assisted Solution

by:blue-genie
blue-genie earned 166 total points
ID: 24084283
flash players garbage collection is not as robust as Java or .NET - you can't force it to happen.
by removing item and deleting references you free them up to be garbage collected but it may not happen immediately.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now