如何解决使用UIGraphicsGetImageFromCurrentImageContext时因内存问题而终止?
问题描述:
在我的绘图应用程序中,我使用UIImage在其上缓存绘图。如何解决使用UIGraphicsGetImageFromCurrentImageContext时因内存问题而终止?
下面的代码行导致内存问题:
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);
self.cacheImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
如何使用UIGraphicsGetImageFromCurrentImageContext
不会造成内存泄漏?
任何帮助将不胜感激。提前致谢。
答
使用这可能会对你有所帮助。 它帮助我在我的情况
@autoreleasepool {
// Write your code here
}
它工作正常,现在 谢谢你这么多 – Abdelrahman
感谢@Abdelrahman –