0

I am working on an animation app, That used cocosbulder files. I am adding scenes by,

[[CCDirector sharedDirector] replaceScene:[CCTransitionCrossFade transitionWithDuration:0.5f scene:[CCBReader sceneWithNodeGraphFromFile:@"SongLoadingScene.ccbi"] ]];

It is generate memory warnings in iPad1.I have try some codes in dealloc() in each scene.

 -(void)dealloc{

[[CCSpriteFrameCache sharedSpriteFrameCache] removeSpriteFrames];
[[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
[[CCTextureCache sharedTextureCache] removeUnusedTextures];
[[CCTextureCache sharedTextureCache] removeAllTextures];
[[CCDirector sharedDirector] purgeCachedData];

[super dealloc];
}

It doesn't work. After 5 to 7 scenes loaded, app get memory warnings and crashing happens. It uses about 500Mb when the crashing happens. How can i get rid of this.

Susitha
  • 3,339
  • 5
  • 27
  • 41
  • 1
    You need to perform an in-depth analysis of the resources in use by your app (use Instruments), locate potential memory leaks (use static analyzer), and come up with ways to reduce memory consumption (ie PVR compressed/fewer/lower resolution/16-bit color depth textures). As is this question is too broad, and like I said before, indiscriminately purging caches will only get you into more trouble. FYI on iPad 1 you can expect to have at best ~130 MB of free memory available, with initial memory pressure warnings occuring around 80-100 MB memory usage. – CodeSmile Mar 13 '14 at 11:24
  • 2
    Alternative: don't publish your app on iPad 1. The iPad 2 already has twice the memory (512 MB), and iPad 1 market penetration is very low, so low indeed that the time spent (I'm thinking about a week) on making the app work on iPad 1 may well cost you more than you get back from additional sales. – CodeSmile Mar 13 '14 at 11:26
  • Thanks @LearnCocos2D, Problem is app consuming more and more memory when opening new scenes. There is no decrement in memory usage means, unreleased objects. App file is only 40Mb and how can grow into such level. There are huge amount of graphic files there. It also included graphics for iPad retina. I have not used any image compressions. Can you suggest any free image compression tools. – Susitha Mar 14 '14 at 09:22
  • You may want to read this: http://www.learn-cocos2d.com/2012/11/optimize-memory-usage-bundle-size-cocos2d-app/ Also bundle size (image file size) is not equal to memory usage, not the least bit. Ie a 16 MB texture can easily be less than a megabyte as a PNG file. – CodeSmile Mar 14 '14 at 09:45
  • if you think this is memory crash then make sure to check following things. 1- if you have retain some objects, you must release them. 2- use sprite sheet instead of simple images, 3- load graphics in rgb RGB444 – Muhammad Shauket Oct 19 '16 at 09:20

0 Answers0