I'm working on a major update to one of my applications and trying to cut down memory usage and making it cleaner and faster. I was using Instruments to profile the app and I was looking at the UIImage allocations, I have about 10 when the app starts out (although one is a status bar icon? Dont know why thats included). When i open up my Settings view controller (which is in a split view controller on iPad) it has basically an image with every table view cell, which is a lot. Presenting it for the first time adds 42 images. when I dismiss this view controller, there is still 52 images, when there should be only 10 now. If I present the controller again, there are now 91 images. This keeps going up and up. Instruments doesn't say there is a leak and I can't figure out what is happening. Each cell sets an image like
cell.imageView.image = [UIImage imageNamed:@"Help-Icon"];
How can I figure out why these images are not being released?
EDIT:
I think Its deallocating the images now. I changed from setting the imageView image directly to setImage:
, so a table cell looks like this now:
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = NSLocalizedString(@"Homepage", @"Homepage");
UIImage *cellImage = [UIImage imageNamed:@"Homepage-Icon"];
[cell.imageView setImage:cellImage];
[MLThemeManager customizeTableViewCell:cell];
return cell;
MLThemeManager
is a singleton that using a theme class to set properties of the cell to a theme, like the text label color, highlighted color, detail text label color, and background color.