我在谷歌上搜索了与 UIImage 相关的内存问题,发现很多线程都在谈论这个问题,但没有真正的帮助或解决方案。
我知道当我们使用-imageNamed:
对象时会被缓存,所以最好使用initWithData:
. 当我们使用drawRect:
andUIGraphicsGetImageFromCurrentImageContext()
时,图像会被缓存吗?
同样在以下代码中:
CGImageRef tmp = CGImageCreateWithImageInRect(imageToCrop.CGImage, clippedRect); //pull the image from our cropped context UIImage *cropped = [UIImage imageWithCGImage:tmp];//UIGraphicsGetImageFromCurrentImageContext();
CGImageRelease(tmp);
尽管文档中没有关于此的参考,但是否进行了缓存?我们如何释放被缓存消耗的内存?