【发布时间】:2014-10-08 22:28:32
【问题描述】:
我正在尝试将图像从 UIImagePicker 复制到文档目录。我正在使用@"UIImagePickerControllerOriginalImage" 键从 UIImagePickerDelegate 的字典中获取原始图像。我正在使用UIImagePNGRepresentation 将图像写入文件。当我添加(重复该过程)高分辨率图像(图像大小约 20 mb)时,我遇到了内存问题。
我分析并使用了 Xcode 的内存泄漏功能,它放大了以下导致泄漏的代码。
@autoreleasepool {
imagesData = UIImagePNGRepresentation(images);
[imagesData writeToFile:name atomically:NO];
imagesData = nil;
//[UIImageJPEGRepresentation(images, 1.0) writeToFile:name atomically:YES];
}
我在这里看到了很多关于UIImagePNGRepresentation 引起的内存泄漏的问题。但是我还没有找到合适的解决方案来解决我的问题。需要帮助。
【问题讨论】:
标签: ios iphone memory-management memory-leaks uiimage