Solved

Flash as 3.0 Loader Memory extending

Posted on 2009-03-31
7
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

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!

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

726 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