Hello there,
I have a question about garbage collection:
I am using a MVC pattern for a photo gallery website.
Every view displays a thumb viewer/controller and an image loader.
Each view extends an abstract class that has a close() method that looks like this
//AbstractViewer class
public function close():void {
while(this.numChildren) {
var d:DisplayObject = getChildAt(numChildren-1);
trace("removing")
removeChild(d);
d=null
}
dispatchEvent(new ViewEvent(ViewEvent.CLOSE));
}
This method is invoked when I change from one view to another. But according to my stats graph the RAM memory is not freed when the view is changed but new memory is allocated to open a new view.
This is the method I use for changing views:
//Main Class
private function sectionChanged():void {
var oldDisplay:AbstractView = currentDisplay;
logo.visible=false;
switch(String(data.currentSection.@type)) {
case "intro":
currentDisplay = new Intro(data, this.stage);
logo.visible=true;
logo.changeColour(0xFFFFFF)
break;
case "text":
currentDisplay = new Text(data, this.stage);
break;
case "blog":
currentDisplay = new Blog(data, this.stage);
break;
case "exhibition":
currentDisplay = new Exhibition(data, this.stage);
break;
case "contact":
currentDisplay = new Contact(data, this.stage);
break;
case "archive":
currentDisplay = new Archive(data, this.stage);
break;
}
oldDisplay.addEventListener(ViewEvent.CLOSE, initDisplay,false, 0,true);
oldDisplay.close();
bg.changeColour(int(data.currentSection.@colour.split(",")[0]))
}
My memory is not constantly going up but only when I change view.
Any ideas?
Thanks!