Memory overflow problem

Memory overflow problem
0.0 0


Hello ppl,
My game has some 5-7 1k textures. the game runs on ipad 3(with occasional low memory warning ) but crashes on ipad 2.
i use spritecache addsprtiewithfile …. at the end of the scene (onExit of the main layer) i removesprite from the cache … then i remove unused texture from texture cache
i also remove specific textures by name… but in the activity monitor the real memory keeps increasing but no leaks….

i don’t retain any of the objects to my knowledge( i use create and not new). And the things i add to ccdictionary i remove it at the end…

What should i do? how to make sure the memory is deallocated?

Any help would be appreciated.



>What should i do? how to make sure the memory is deallocated?
You can make temporary change in cocos2dx sources: insert static variable int s_count into CCNode class, increment it in CCNode constructor, decrement in destructor and print it somewhere else (or right in destructor).

You also can go further and create static variable std::set<CCNode *> s_instances with all alive instances of CCNode, and track which nodes are not deleted in debugger.

P.S. After calling new object has retainsCount() == 1, and CCDictionary increments retain count on adding / decrements on removal. So you should call obj->release() after adding to CCDictionary.


Yes i did that … only a few nodes are released … a lot of them are retained… any suggestions?

the scene and all the objects in the scene are autp release objects….


Hello ppl ,
Found out and fixed the node count … removed all unused textures and sprite frame cache(checked the log for both texture and sprite frames) … but the overall memory keeps increasing…



I’ve answered a similar question days ago:

Make sure your sprites are removed (from it’s parent) and deleted before calling removeUnusedTextures() as if they are still used it won’t do anything.