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
Solved

Flash as 3.0 Loader Memory extending

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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,…
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): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

791 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