I have a game with rounds. At the end of every round, the easiest way for me is to just reload all my code and start the next round. I actually take the stage object and call again as following : gameStage = new Kinetic.Stage({...})
By doing that I had in mind that the stage will be recreated, and all layers,objects and the stage itself are removed (destroyed) from memory. I have a feeling that the old stage with all its objects stay in memory even after I create the NEW stage. Is that true? Should I first call destroychildren for each layer, then remove each layer, and then destroy the stage, before I call the NEW stage? What would be the best way to clear the stage completely, and start over adding new layers from scratch?
Thanks Eli
stage=new Kinetic.Stage causes javascript to dereference the old stage and all its objects.
When the garbage collector runs it will release all memory used by the dereferenced objects.
After garbage collection, your old stage is gone and the memory it used is freed into the memory pool.
Bottomline: stage=new Kinetic.Stage will do the job of clearing your old stage.