something about memory release

something about memory release
0.0 0

#1

:slight_smile: hi everybody:
when I replace scene,I use CCTextureCache::sharedTextureCache()->removeUnusedTextures(); CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames();
to release memory.It works but not very well.I find that there are still about 20 - 30M memory I can’t release.What should I do to release memory.
Thank u a lot.:slight_smile:


#2
CCTextureCache::sharedTextureCache()->removeUnusedTextures();
CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames();

The above code only remove the objects which retainCount() is equal to 1.
Maybe the retainCount is larger than 1. You can try to use

CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFramesFromFile
CCTextureCache::sharedTextureCache()->removeTexture

to remove the textures and spriteframes.


#3

I have found that removeUnusedSpriteFrames must be called before removeUnusedTextures. Otherwise the textures in the spriteframes will not be removed.

CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames(); 
CCTextureCache::sharedTextureCache()->removeUnusedTextures();

#4

hi, when is the best moment to call those methods? onExit? scene destructor?

Thkns