Analyze检测内存泄漏的一些解决记录
2015-10-14 本文已影响962人
程序媛coco
- Variable '****' is uninitialized when captured by block
NSUInteger shaiwuID;
if ([shaiwu isKindOfClass:[HHGuide class]]) {
...
shaiwuID = shaiwuObj.guideID;
} else if ([shaiwu isKindOfClass:[HHDiscount class]]) {
...
shaiwuID = shaiwuObj.discountID;
}
QQ20151014-0@2x.png
出现这个问题是,在completed的block里shaiwuID有可能没有被初始化。因为shaiwuID的赋值是在if - else if 里缺少默认的赋值,把第二个条件改为esle即可。
- call to function 'CGImageCreateWithMask' returns a Core Foundation Object With +1 retain count
调用CGImageCreateWithMask
方法,会返回一个对象,并且它的的引用计数器会自动加1,当对象销毁时需要进行一次release。修改如下:
CGImageRef newImageRef = CGImageCreateWithMask(grayImage, mask);
UIImage *grayScaleImage = [UIImage imageWithCGImage:newImageRef
scale:1
orientation:self.imageOrientation];
CGImageRelease(newImageRef);