Friday, 6 September 2013

Cocos2d: is there a way to know which images are still loaded in memory?

Cocos2d: is there a way to know which images are still loaded in memory?

I am using Cocos2d 2.0 and XCode 4.5.2 and I do wonder how I can detect
which spritesheets/images are still on memory at a specific time.
Example: In Scene I load images.pvr.ccz spritesheet, then I call
replaceScene loading Scene2. Whilst Scene2 is running I want to see if
images.pvr.ccz is still in memory as the resident memory increases at each
scene.
Should I use some instrument tool or shall I instead add some breakpoint
in the texture cache related classes?
I do add the images to the frameCache as following:
[[CCSpriteFrameCache sharedSpriteFrameCache]
addSpriteFramesWithFile:@"images.plist"];
batchNode = [CCSpriteBatchNode batchNodeWithFile:@"images.pvr.ccz"];
[self addChild:batchNode];



Additional details - not needed
I have the following beheaviour: every time I replace a scene the memory
increases by the "x" MB that could correspond to the spritesheet size.
I added those calls at the init method of each scene, however the memory
still increases:
[CCAnimationCache purgeSharedAnimationCache];
[CCShaderCache purgeSharedShaderCache];
[[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];

No comments:

Post a Comment