I want to caching image for 91 images. And All images are about 50mb. I see that a lot of memory is used up.
My code is here. What is the best way for efficient memory?
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;
}