【发布时间】:2014-07-20 02:54:51
【问题描述】:
在我的 iPad 应用程序中,我使用 ALAsset 和以下代码从 Photo Stream 加载了 100 张图像:
ALAsset *asset = [assets objectAtIndex:[sender tag]];
ALAssetRepresentation *representation = [asset defaultRepresentation];
UIImage *image = [[UIImage alloc] initWithCGImage:[representation fullScreenImage]
scale:1.0f
orientation:0];
一切都很完美。但是当我将它作为 JPEG 文件缓存到文件系统,然后使用UIImage *image = [UIImage imageWithContentsOfFile:fullPath] 再次加载它们时,应用程序崩溃并出现内存警告,我可以在分析器中看到它确实使用了大量 RAM。
为什么会这样?
【问题讨论】:
-
使用@autorelease循环释放内存。
-
类似于下面的代码: - (void)useALoadOfNumbers { for (int j = 0; j
-
我现在正在尝试这个。我尝试在不同的地方使用它,但没有成功。
-
嗯,问题是我没有实际的循环。我知道@autoreleasepool 并尝试以不同的方式使用它。
标签: ios objective-c uiimage memory-warning