Did a test on instrument and found memory leak for this piece of code for my iphone (IOS 4.1), but does not have memory leak when run on simulator (IOS 4.3) :
- (void)viewDidLoad {
UIImageView *backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"background.png"]];
[self.tableView sendSubviewToBack:backgroundView];
self.tableView.backgroundView = backgroundView;
[backgroundView release];
backgroundView = nil;
}
Instrument show [UIColor allocWithZone] responsible for the memory leak.
Is this a bug of IOS 4.1 or mistake from my code? Should I ignore this if this belongs to UIKit memory leaks?
I don’t see a leak in your code. UIKit might be allocating some one time memory for the first time initialization.