美文网首页
Analyze检测内存泄漏的一些解决记录

Analyze检测内存泄漏的一些解决记录

作者: 程序媛coco | 来源:发表于2015-10-14 17:50 被阅读962次
    1. 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即可。


    1. call to function 'CGImageCreateWithMask' returns a Core Foundation Object With +1 retain count
    QQ20151014-2@2x.png

    调用CGImageCreateWithMask方法,会返回一个对象,并且它的的引用计数器会自动加1,当对象销毁时需要进行一次release。修改如下:

        CGImageRef newImageRef = CGImageCreateWithMask(grayImage, mask);
        UIImage *grayScaleImage = [UIImage imageWithCGImage:newImageRef
                                                      scale:1
                                                orientation:self.imageOrientation];
        CGImageRelease(newImageRef);
    

    相关文章

      网友评论

          本文标题: Analyze检测内存泄漏的一些解决记录

          本文链接:https://www.haomeiwen.com/subject/wswocttx.html