Memory not being cleared when moving between scenes, am I understanding this memory management thing correctly?



I have a scene with sprites, I used create() to place my sprites, batchnodes, etc. I didn’t use any retain().

When I check the memory usage, it never goes down, always up. I thought memory gets cleared when I move from one scene to another automatically, but it doesn’t.

What I did was trying to manually clear memory upon exit of scene. I didn’t use onExit, instead putting my code inside the (~) function.

I tried removing children, setting variables to null, deleting them, releasing them, purging spriteframecache, removing unused sprites, etc, none of these method reduced memory usage at all.

What am I doing wrong? I feel I’m missing something fundamental here. I read every thread on the topic here and can’t see it.



I managed to purge memory by calling


before select scenes (all except preloading).