I made a flash game where you fly a plane and you have to grab circles and avoid parachutes and stuff. Here is a screen of the game for you to understand what im talking about:

The problem that i have is the memory usage because i want to migrate it to iphone with air. When im in a menu there is no problem, the aplication uses around 40 mb. But when im playing the memory goes up like an arrow. I took a screen of the Monster Debugger graphic. Here it is:

The thing is that i have various classes for each elements that fall from the sky. for the parachutes, for the surfers, for the lines of circles and for the bonuses. They are all pretty simmilar so i will copy only the parachutes class that is this:
package {
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.*;
import ascb.util.NumberUtilities;
import myGlobal;
import flash.geom.*;
import com.demonsters.debugger.MonsterDebugger;
public class paracaidistasClass extends MovieClip {
private var n:Number = 0;
private var _rotacionDelAvion:int = 1;
private var temporizador:Timer=new Timer(myGlobal.paracaidistasTemporizador[myGlobal.nivel - 1],0);
public function paracaidistasClass() {
// constructor code
temporizador.start();
temporizador.addEventListener(TimerEvent.TIMER, emisor);
addEventListener(Event.ENTER_FRAME, altura);
}
private function altura(e:Event):void{
if (myGlobal.detener == false){
this.y = this.y - myGlobal.altura;
}
}
private function emisor(e:TimerEvent){
if (myGlobal.detener == false){
temporizador.delay = NumberUtilities.random(myGlobal.paracaidistasMinimoDelay[myGlobal.nivel - 1], myGlobal.paracaidistasMaximoDelay[myGlobal.nivel - 1]);
var paracaidista = new paracaidistaClass;
this.addChildAt(paracaidista, 0);
paracaidista.y = NumberUtilities.random(-350,50);
myGlobal.cantidadDeParacaidistas = this.numChildren;
addEventListener(Event.ENTER_FRAME, movimiento);
}
}
private function movimiento(event:Event):void{
if (myGlobal.detener == false){
for (var i:Number=0; i<this.numChildren;i++){
getChildAt(i).x = getChildAt(i).x - (myGlobal.velocidad - (pasarAPositivo(myGlobal.rotationDelAvion) / 12));
getChildAt(i).x = getChildAt(i).x - 1;
if (getChildAt(i).localToGlobal(new Point(stage.x,0)).x < -200){
removeChildAt(i);
myGlobal.cantidadDeParacaidistas = this.numChildren;
}
}
}
//delete all parachutes
if (myGlobal.reiniciar == true){
for (var d:Number=0; d<this.numChildren;d++){
removeChildAt(d);
myGlobal.cantidadDeParacaidistas = this.numChildren;
}
}
}
private function pasarAPositivo(value:int):int{
var _rotacionPositiva:int;
_rotacionPositiva = value;
if (_rotacionPositiva < 0){
_rotacionPositiva = _rotacionPositiva * -1;
}
return _rotacionPositiva;
}
}
}
Well. Ass you can see i delete the parachutes that are out of stage or hit so the memory usage should stabilize in some poin. I also check and i never pass the 3, 4 children of parachutes. So, i dont understand why only when y remove the entire class that is at the end of the level the memory drops and why it isnt stable and keeps growing when y remove the childs that im not using. I hope y was clear enought and someone knows whats the problem. Thanks in advance.
Not sure exactly what’s going on in the emisor Timer callback, but your adding an eventListener every time the conditions are met. If it is one for every parachute, then you don’t remove that eventListener anywhere. You really only need one ENTER_FRAME eventListener for the whole app and just have that update the child classes.