I have an About View which I push onto a NavigationController. The view has one UILabel which is connected to an IBOutlet. In viewDidLoad I populate the UILabel with the bundle version number (a string). Testing with instruments suggested that the line marked with a comment is leaking memory: –
viewDidLoad {
[super viewDidLoad];
self.title = @"About";
// Line below is the suggested culprit ***
NSString *versionLabel = [[NSString alloc] initWithFormat:@"Version %@",
[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey]];
self.applicationVersion.text = versionLabel;
[versionLabel release];
versionLabel = nil;
}
I’m assuming it is suggesting the NSString and not anything else on the line …
My questions is Why ?
It may actually be the mainBundle or infoDictionary that is leaking – it is possible that the system is caching one or other of those and thus they are being created and then never released.
Try adding in to your applicationDidFinishLaunching the code:
Without any other code and see if Leaks points to that line as the location of the leak. In that case, caching is the issue and you can ignore it.