我想缓存 91 张图像的图像。所有图像约为 50mb。我看到很多内存都用完了。
我的代码在这里。高效记忆的最佳方法是什么?
lG2Image[0] = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"background" ofType:@"png"]];
lG2Image[1] = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"myimage1" ofType:@"png"]];
lG2Image[2] = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"myimage2" ofType:@"png"]];
...
UIImageView* tmp;
for (int i=0; i<91; i++) {
tmp = [[UIImageView alloc] initWithImage:lG2Image[i]];
[_window addSubview:tmp];
[tmp removeFromSuperview];
tmp = nil;
}