I have a very strange problem . I have a scrollView
, in which i load images that are taken from the web. it works great on the iPad, and the memory is stable and low , one 35MB .
Every page i load only the relevant images and remove the rest by setting UIImageView=nil
.
The problem starts when the images that i load into the scroller are not coming from the web, but pre loaded from disk,than as long as i scroll more, the memory rise up and up from 30 to 200. It seems when the image is not from the web( offline mode) , he wouldnt release the images, but when its online mode, everything works perect .
Here is how i check offline or online to load the image to the scroller :
//this method gets: or image url string(online), or UIImage(offline).
[self.imageOperationQueue addOperationWithBlock:^
{
UIImage *image ;
if(!isOffLineMode)
image=[UIImage imageWithData:[NSData dataWithContentsOfURL:userUrl] scale:1.0];
else
image=[dic objectForKey:@"userImage"];
if (image)
{
UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale);
[image drawAtPoint:CGPointZero];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
if (image != nil)
{
[[NSOperationQueue mainQueue] addOperationWithBlock:^
{
UIImageView *view=thisCell.userImage;
view.image=nil;
view.image=image;
}];
image=nil;
}
}];
In both cases i clear images with imageview.image=nil;
.
Problems occur only in offline mode .