I have UIImage outlet in TableViewCell which I will use it later in UITableView. When I check this in instruments I get some memory leak on UIImageView. I’m not releasing the UIImageView in the UITableViewCell, because I get exc_bad_access if I release it in the tavleViewCell.
My question is where do I release this UIImageView?
Update
CustomCell.h
@interface CustomCell : UITableViewCell {
IBOutlet UIImageView *customImage;
}
@property(nonatomic, retain) UIImageView *customImage;
@end
CustomViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.customImage.hidden = [[self.customImageList objectAtIndex:indexPath.row] boolValue];
return cell;
}
UITableView caches cells for later reuse. That shows up as a memory leak but you can eventually reuse the cell so it is not really leaked.
What you can do is release the imageview that is retained by your custom UITableViewCell when the cell scrolls off screen, but that could lead to performance problems if the image is needed again when scrolling.