Solved

Flash as 3.0 Loader Memory extending

Posted on 2009-03-31
7
290 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

760 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

21 Experts available now in Live!

Get 1:1 Help Now