I am using EaselJS and Box2DWeb to create an arrow shooting game. Every time an arrow collides with another body, it dies, and I call this function:
if(body.dead){
removeActor(body.GetUserData()) //the user data is the actor object (sprite) of the arrow
world.DestroyBody(body);
delete body;
bodies.splice(i, 1);
i--;
}
and the removeActor function:
// remove actor and it's skin object
var removeActor = function(actor) {
if(actor){
stage.removeChild(actor.skin);
actors.splice(actors.indexOf(actor),1);
delete actor;
}
}
I tried continuously creating arrows and checking to see if the memory has been freed (using chrome task manager), but the memory used only increases. Is there a way for me to completely remove these objects from memory?