Hi,
I am using the following code to load the sprite sheet in my application.
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@" Player gun draw fast animation.plist"];
CCSpriteSheet *playerGunFastDrawSheet = [[CCSpriteSheet alloc] initWithFile:@"Player gun draw fast animation.png" capacity:3];
CCSprite *spritePlayerGunFastDraw = [CCSprite spriteWithSpriteFrameName:@"Player gun draw fast animation_01.png"];
[playerGunFastDrawSheet addChild:spritePlayerGunFastDraw];
NSMutableArray *playerGunFastDrawArray = [NSMutableArray array];
for (int i = 1; i <= 3 ; i++)
{
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"Player gun draw fast animation_%02d.png",i]];
[playerGunFastDrawArray addObject:frame];
}
CCAnimation *playerGunFastDrawAnimation = [[CCAnimation alloc ]initWithName:@"playerGunFastDraw" delay:0.166f frames: playerGunFastDrawArray];
CCAnimate *actionGunDrawFastAction = [[CCAnimate alloc ]initWithAnimation:playerGunFastDrawAnimation restoreOriginalFrame:NO];
id actionAfterFD = [CCCallFunc actionWithTarget:self selector:@selector(fastDraw:)];
[self.playerH runAction:[CCSequence actions:(CCFiniteTimeAction*)actionGunDrawFastAction, actionAfterFD, nil]];
self.flagFastDraw = 1;
[playerGunFastDrawSheet release];
[playerGunFastDrawAnimation release];
[actionGunDrawFastAction release];
And I am using the code to release all the unused sprites.
[[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
But the problem is when I run the Instruments Object allocation tool, it is showing most memory is consumed by CCSpriteFrameCache and it is not deallocing. So, the memory for object allocation is increasing over 100MB in application. I have 14 CCSpriteFrameCache code in my application. The application is crashing due to this.
How can I release the CCSpriteFrameCache instantly after its use. Please suggest any ideas and please suggest about my code where I am wrong ?
Thank you.