Hi Li
Sorry I've taken a while to respond, I've been away from this project
for a couple of weeks. Its tricky to explain but hopefully the
following will give you an idea of what I'm doing.
In my main loop I'm adding things like aircraft, missiles, particles
etc at any given interval. I have methods to add the entities and
within the constructors of each entity I'm adding simple geometry
(planes mainly) and then I'm finioshed with them,I remove them.
public function addEnemyMissile(startPos:Vector3D):Boolean {
var missile:Missile = new Missile();
missile.initialise();
missile.x = startPos.x;
missile.y = startPos.y;
missile.z = startPos.z;
missile.lookAt(camera.position);
scene.addChild(missile);
missiles.push(missile);
return(true);
}
Then the missile constructor adds some child geometry to it (Missile
inherits from ObjectContainer3D)
public function Missile(isEnemy:Boolean=false)
{
super();
plane1=(Helper3DLite.createPlane(getWidth(), getHeight(), 1, 1,
getColour()));
plane1.bothsides = true;
plane1.rotationZ = 90
this.addChild(plane1);
this.layer = new Sprite();
setFilters();
}
Then when its removed
override protected function
removeEntity(entity:BaseEntity3DLite):void
{
if(entity is Missile){
for (var i:int = 0; i < missiles.length; i++) {
if (entity == missiles[i]) {
missiles.splice(i, 1);
break;
}
}
....
entity.parent.removeChild(entity);
}
I basically create an object that inherits from ObjectContainer3d, add
some child geometry in the constructor and then add it to a list. When
its removed, I remove it from the list and its parent.
I've had to strip out and simplify a lot of the code to try and
explain it, theres a lot of other stuff going on. Without posting all
my source code, its difficult to try and explain. Not sure if I make
sense but hopefully you can understand my process. Maybe you can spot
something that could be causing a memory leak?
On Jun 2, 1:18 pm, Li <[email protected]> wrote:
> Well yes, that's absolutely possible. Could you abstract some of your code
> here, or an equivalent so I can debug for a memory leak in the engine?