Search code examples
objective-ccocos2d-iphoneautomatic-ref-countingccsprite

ARC CCSprite memory leak


I have following code

__weak CCSprite *paddleSprite = [CCSprite spriteWithFile:@"paddle.png"];

Instruments is detecting memory leaks and is telling me that I have memory leak on this line.

Does anybody knows something about this. Isn't CCSprite an autorelease object?


Solution

  • I solve this problem. The problem was actually in Box2d. For b2BodyDef I was having this:

    paddleBodyDef.userData = (__bridge_retained void*)paddleSprite;
    

    But this was incorrect (in my case). Correct is this

    paddleBodyDef.userData = (__bridge void*)paddleSprite;
    

    Also in dealloc method I put

    paddleBodyDef.userData = NULL;