我的应用程序相对简单 - 基本上是UIScrollView
查看几百个(大)JPEG。然而,它始终因“内存不足警告”而崩溃
滚动视图由三个UIImageView
s(previousPage
、currentPage
和nextPage
)组成。开始时,每次滚动当前页面时,我都会UIImageView
用 new “重置”三个 s UIImages
。
NSString *previousPath = [[NSBundle mainBundle] pathForResource:previousName ofType:@"jpg"];
previousPage.image = [UIImage imageWithContentsOfFile:previousPath];
currentPage.image = [UIImage imageWithContentsOfFile:currentPath];
nextPage.image = [UIImage imageWithContentsOfFile:nextPath];
在 Allocations 中运行,#living 对象UIImage
的数量在应用程序运行期间保持不变,但 #transitoryUIImage
对象的数量可能会增长得相当高。
这是一个问题吗?有什么方法可以“释放”这些UIImage
对象吗?我是否认为这是内存泄漏的根源?