Best Scene to Scene Memory Management Example?

Best Scene to Scene Memory Management Example?
0.0 0


I’m looking through the Cocos2d-x HTML5 examples and haven’t been able to locate any good examples of Scene management where for example:

  1. A scene is loaded into the memory which itself builds a series of sprite anamations and onTouch callbacks.

  2. Upon navigating to the next scene the previous scene is released from memory.

  3. Upon navigating back to the previous scene the child assets are reconstructed.

I’m probably approaching this wrong and would love any input. Have tried many options inserted to my original scene’s onExit function like:

this.getParent().removeChild(this,true); // removes this scene from memory on exit?

AnySceneBuiltSprite.removeFromParent( true ); // i’ve added this into onExit and applied it to every single sprite created by the scene

Also when i’ve tried these above solutions something is compounding the memory… maybe the animationCache i don’t know. Any memory debugging function recommendations would be great too. I’m working on this in Eclipse at the moment.

Lastly, A tutorial focusing on memory management and with a range of memory release examples would be simply awesome and solve a lot of newcomers issues.


So in further tests I found I wasn’t applying removeFromParent( true ) to every single sprite and doing so has made results better but not solved it. When using scene changing like the Moon Warriors example something is still stacking into the memory and after several scene changes back and forth the memory gets so full the app crashes.

What is the best method to release a scene from memory?

What is the best memory monitoring function or IDE tool i can use to monitor the device memory and these failures in real time?