Objective c, Memory management of instance members

First you should not look at the retaincount, it not really reliable.

Second your property is set to retain. So when you assign some thing to it, it will increase the reatincount. As will alloc.

Doing it like this you are leaking:

self.detailedResultsMapViewController = [[DetailedResultsMapViewController alloc] initWithNibName:@"DetailedResultsMapViewController" bundle:nil];

you should do:

DetailedResultsMapViewController *vc = [[DetailedResultsMapViewController alloc] initWithNibName:@"DetailedResultsMapViewController" bundle:nil];
self.detailedResultsMapViewController =vc;
[vc release], vc= nil;

Or use Autorelease:

self.detailedResultsMapViewController = [[[DetailedResultsMapViewController alloc] initWithNibName:@"DetailedResultsMapViewController" bundle:nil] autorelease];

Leave a Comment