• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

Flash as 3.0 Loader Memory extending

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
aditkohli
Asked:
aditkohli
  • 2
3 Solutions
 
asaivanCommented:
try setting sp to null, after you've removed it from the stage.

e.g.

sp = null;
0
 
bridgetimillerCommented:
Try using Loader.unloadAndStop().  This is allow help clear all references to the Loader and make it accessible for garbage collection.
0
 
bridgetimillerCommented:
loaderOjb.unloadAndStop() in your case. :)
0
 
blue-genieCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now