ios – 存储在CGImageRef中的对象的潜在泄漏

ios – 存储在CGImageRef中的对象的潜在泄漏,第1张

概述在 Xcode Analyze下运行我的代码我偶然发现了以下块 - (UIImage *)imageWithFilter:(CIFilter *)filter{ CIContext *ctx = [CIContext contextWithOptions:nil]; CGImageRef imageRef = [ctx createCGImage:filter.outputIma 在 Xcode Analyze下运行我的代码我偶然发现了以下块
- (UIImage *)imageWithFilter:(CIFilter *)filter{    CIContext *ctx = [CIContext contextWithOptions:nil];    CGImageRef imageRef = [ctx createCGImage:filter.outputimage fromrect:CGRectMake(0,self.size.wIDth,self.size.height)];    return [UIImage imageWithCGImage:imageRef];}

Xcode抱怨潜在的内存泄漏

到底是怎么回事?我该怎么做呢?

解决方法 以下看起来像一个修复程序,仍然不确定这是否是保留引用处理此方法的最佳方法?
- (UIImage *)imageWithFilter:(CIFilter *)filter{    CIContext *ctx = [CIContext contextWithOptions:nil];    CGImageRef imageRef = [ctx createCGImage:filter.outputimage fromrect:CGRectMake(0,self.size.height)];    UIImage *image = [UIImage imageWithCGImage:imageRef];    CGImageRelease(imageRef);    return image;}
总结

以上是内存溢出为你收集整理的ios – 存储在CGImageRef中的对象的潜在泄漏全部内容,希望文章能够帮你解决ios – 存储在CGImageRef中的对象的潜在泄漏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1114040.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存