If I have a variable that is declared within a method of a class, should that variable EVER need to be marked for garbage collection (set to null).
for example:
public class MyClass extends MovieClip
{
public function MyClass():void
{
//constructor
myMethodThatLoadsAPage();
}
private function myMethodThatLoadsAPage():void
{
var myVar = new SomeObject(); // in my case, this is a new MC from the library
myVar.newpageButton_mc.addEventListener(MouseEvent.MOUSE_DOWN, loadANewPage);
addChild(myVar);
}
private function loadANewPage(e:MouseEvent):void
{
this.removeChildAt(0); //removes previous page
var myVar = new SomeObject();
addChild(myVar); // display the new page
}
}
I am making a 24/7 kiosk app and am noticing that the “pages” I load from the library using the above technique continually increases the memory usage (using Monster Debugger 3 and testing the SWF from within Flash Pro CS5 on a Mac.)
As I understand it “myVar” are the only references to each “SomeObject” object that gets instantiated. Shouldn’t the fact that myVar is local mean that SomeObject should be available for garbage collection after each new page is loaded?