Memory Warning Level = 2

Memory Warning Level = 2
0.0 0


Hi All…
I make games using cocos2d-1.0.1-0.9.1-x, size game is 150 mb, and resolution 1024x768, I run my games on device ipad1 and android devices (transformers-3.0 asus Honey Comb, acer inconia - 2.2 froyo) after some time the game is stop and close, and memory appear in the warning level = 2 debug xcode …
I run on Instruments Xcode , allocation memory is used more than 90 mb…

for the moving scene I use replaceScene … and I also have tired of trying to erase the memory that is not used, but still the same problem still appears …

and I also have added this code to solve the problem;

  • (Void) applicationDidReceiveMemoryWarning: (UIApplication ) application {

    Free up as much memory as possible by purging cached data objects That can be recreated (or reloaded from disk) later.

* /
cocos2d:: CCDirector:: sharedDirector () > purgeCachedData ;
cocos2d:: CCTextureCache:: sharedTextureCache
> removeUnusedTextures ();
cocos2d:: CCTextureCache:: sharedTextureCache () > removeAllTextures ;
and put this code in every destructur scene…
cocos2d:: CCTextureCache:: sharedTextureCache
> removeUnusedTextures ();

So, does anyone know how to solve this problem?
Thank you for your help ….

memory questions

Please take care of your objects. Are they released correctly?
This thread would be helpful Memory deallocation in Cocos2d-x


Hello I had the same problem on iPad and adding the required code in applicationDidReceiveMemoryWarning solved the problem thank you.
I thought that on memory warnings the caches were purged, I thought it was already done (in the project template) like in the my previous cocos2d-iPhone projects.


Sorry, we forgot it.
#893 is created for it.

BTW: You should only invoke cocos2d:: CCDirector:: sharedDirector () -> purgeCachedData ().


Ok thank you