I am noticing a very strange UITableView memory behaviour. I am writing an image application which displays thumbnails in UITableView. I am retrieving images in a separate thread and storing them in an array. UITableView cellRowatIndexpath reads from that array and sets up cells. According to my understanding, since I am creating UIImages and storing them prior, while scrolling my memory should be fairly constant. But when I scroll, memory consumption is increasing steadily. Surprisingly instruments "live bytes" remain fairly constant while scrolling as expected, but real memory available on iphone as measured by memory tools reports steep increase in memory consumption when i scroll table.
There are no allocations being done while tableview is scrolling, all I am doing is reading image from array and setting it in cell's imageview object.
If I use NSData instead of UIImage from array, as you can see from the code in isMemoryManagementEnabled part, Memory consumption is constant while I am scrolling. somehow UIImage is beahving differently.
Here is the cellAtRowIndexPath code: photoArray is pre populated with either NSData or UIImages.
id t = [self.photoArray objectAtIndex:i];
if(t!=nil && ((NSNull *)t != [NSNull null])) {
NSLog(@"image data found in memory");
if(self.isMemoryManagementEnabled) {
civ.image=[UIImage imageWithData:t];
} else {
NSLog(@"photo retrieved from photoarray");
civ.image=(UIImage*)[self.photoArray objectAtIndex:i];
}
}else{
civ.image=[UIImage imageNamed:@"photoDefault.png"];
}