We have tried two ways to control heap memory allocation to avoid memory overflow which result into a crash after sometime:
-
We are using following statement when exiting the scene
this->removeAllChildrenWithCleanup(true); CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames(); CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFrames(); CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFramesFromFile("AICharacterExpressAnimation.plist"); CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFramesFromFile("AICharacterThinkAnimation.plist"); CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFramesFromFile("AICharacterAggressiveAnimation.plist"); CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFramesFromFile("UserCharacterAnimation.plist"); CCTextureCache::sharedTextureCache()->removeUnusedTextures(); CCTextureCache::sharedTextureCache()->removeAllTextures(); CCDirector::sharedDirector()->purgeCachedData();
-
We have compressed all pvr files to .pvr.ccz and loaded it, also compressed the individual png’s.
But it doesn’t seem to make any difference at all, so please suggest any other solution to control memory.
Thank you in advance.