试图了解仪器中报告的泄漏情况

1 iphone objective-c ios

仪器报告我在代码的第一行有内存泄漏.但是你可以在代码的底部看到我发布了flipcoin对象.我没有其他分配线,所以我不明白可能是什么问题?我猜有一部分内存管理我误解了,有人可以给我一个暗示,这可能会导致这个报告泄漏吗?

flipCoin= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"0000.png"]];
CGRect frameX;
UIImageView *coinFlipImage = [[UIImageView alloc] initWithImage:[UIImage 
    imageNamed:@"0000.png"]];
frameX = coinFlipImage.frame;
frameX.origin.x = (480/2) - (frameX.size.width/2);
frameX.origin.y = (320/2) - (frameX.size.height/2);

[flipCoin initWithFrame:frameX];
flipCoin.animationImages = myImages;
flipCoin.animationDuration = 1.4; // seconds
flipCoin.animationRepeatCount = 1; // 0 = loops forever
//[flipCoin startAnimating];
[self.view addSubview: flipCoin];
[coinFlipImage release];
[flipCoin release];  
Run Code Online (Sandbox Code Playgroud)

非常感谢-Code

the*_*ent 5

你在flipCoin上做了两次init.

来到这里:

flipCoin= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"0000.png"]];
Run Code Online (Sandbox Code Playgroud)

然后在这里:

[flipCoin initWithFrame:frameX];
Run Code Online (Sandbox Code Playgroud)

而不是第二个实例,只需像这样设置框架:

flipCoin.frame = frameX;
Run Code Online (Sandbox Code Playgroud)