iOS-使用VPImageCropper时Analyze 出现Potential leak of an object stored into 'subImageRef'

来源:互联网 发布:微信小说分销系统源码 编辑:程序博客网 时间:2024/05/21 22:31

http://blog.csdn.net/xutianyu930818/article/details/45195851

今天analyze的时候出现这个问题,是用的一个第三方裁剪图片的类叫VPImageCropper,结果发现他里面有问题,看图大家就明白了.在调用CGImageCreateWithImageInRect时subImageRef内存计数+1了,但是在后面用完后却没release.

那么问题来了,这个VPImageCropper是支持ARC的,也就是说系统遇到这边就不好用了,释放不了.这样就会有内存泄露

后来上 stackoverflow 查找 发现这样一段话

ARC does not manage C-types, of which CGImage may be considered. You must release the ref manually when you are finished with CGImageRelease(image);

也就是 在arc模式下 不是什么东西 都可以释放 例如 C-types的对象 都需要手动来进行释放 

加上这句话就好了CGImageRelease(subImageRef)

这时我们再来看下,问题解决了~



0 0