cocos2d-objc
cocos2d-objc copied to clipboard
CCColor memory leak
I'm using SpriteBuilder 1.3.6 with Xcode 6.1.1 (6A2008a) Bug is reproduced on my iPhone 4s with iOS 7.1.1 (no more devices available now).
Steps to reproduce: Just create for instance CCLabelTTF as usual
floatingScoreLabel = [CCLabelTTF labelWithString:@"0"
fontName:@"fontname.fnt"
fontSize:13
[self addChild:floatingScoreLabel];
And there is a leakage occurs. Instrument's leakage tool points to

Possible fix: Adding _CGColorRelease(color); before line #183 removes the leakage
I have the same problem. Thanks slxl, your fix works for me too.
Looks like this is what @slembcke was referring to in https://github.com/cocos2d/cocos2d-spritebuilder/pull/1303#issuecomment-93494449
As CCColor are immutable there is no need to keep re-allocating the _color - once it has been created it can stay the same, which is what https://github.com/cocos2d/cocos2d-spritebuilder/pull/1303 does.
[If a CCMutableColor (please no!) is ever added then it needs revisiting!]
Looks like https://github.com/cocos2d/cocos2d-spritebuilder/issues/1168#issuecomment-93544371 was the previous discussion/proposed fix.