开发者

iPhone: CALayer Memory Leak question

Would the code bellow cause my code to leak? More specifically, am I responsible for releasing the newImage or the contents of mainPageLayer (which is a CALayer object)? I get a memory warning every 4th time that method is called, but cant figure out why...

I also can't figure out why mainPageLayer.contents = [newImage CGImage]; t开发者_Go百科hrows a warning that the argument I am passing is of an incompatible pointer time. The image shows up just fine inside the layer.

-(void)setPrimaryPage:(UIImage *)newImage {
 pImageSizeWidth = newImage.size.width;
 pImageSizeHeight = newImage.size.height;

 [mainPageLayer setFrame:CGRectMake(0, 0, pImageSizeWidth, pImageSizeHeight)];
 mainPageLayer.contents = [newImage CGImage];
}


the contents property is defined as follows:

@property(retain) id contents

which means that the CGImageRef from newImage is retained. Whether your code leaks isn't clear from your code: There's not enough context. It will only leak if newImage was retained upon calling your setPrimaryPage:.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜