Search code examples
iphonememory-leaksuiimageviewuiimagedidreceivememorywarning

iPhone memory doesnt free up after calling nil


I am using Apple's ScrollingSuite for displaying a large scrollview with a number of large images.(768 x1024) The image of an imageview is set by

controller.numberImage.image = [self.contentList objectAtIndex:page]; 

where, numberImage is an UIImageView and controller is an object of the viewcontroller which I am adding in the scrollview. I am setting the image as nil when the page is scrolled out of view by

controller.numberImage.image = nil;

But the problem is my app runs out of memory receiving Memory Warning when scrolled through the images. Each time a new image is shown, I can see memory increasing in instruments tool (Memory Tag 70) which on googling turns out ImageIO. Please help me with this

Thanks in advance


Solution

  • Try removing the imageView ( [controller.numberImage removeFromSuperview]; ), then adding it back before it is about to come into view ( [controller addSubview:[[UIImageView alloc] initWithImage:[self.contentList objectAtIndex:page]]]; ) possibly?