Hi! I'm trying to remove simple objects from memory, but when I call removeChildren memory usage rose :/ And I don't why ? And how can I remove objects ?
package {
import flash.display.DisplayObject;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.system.System;
public class Main extends Sprite {
public function Main()
{
for (var i:int = 0 ; i < 1000;i++) {
var addBouncerButton:SimpleButton = new SimpleButton();
addBouncerButton.x = 100;
addBouncerButton.y = 10;
addBouncerButton.name = "Btn"+i;
addChild(addBouncerButton);
}
stage.addEventListener(Event.ENTER_FRAME, update);
stage.addEventListener(KeyboardEvent.KEY_DOWN, remove);
}
private function remove(e:KeyboardEvent):void
{
trace("Children : " + this.numChildren);
trace(System.totalMemory * 1024 + " kb");
if(this.numChildren > 0)
var o:DisplayObject = removeChildAt(this.numChildren - 1);
o = null;
}
private function update(event:Event):void
{
}
}
}