Why is MKMapView saved after its parent controller has been removed from the navigation stack?

I found several questions regarding this on SO and elsewhere, but no one has a definitive answer. As far as I can tell using ARC, my MKMapView is not released (or at least leaves garbage on the heap) when the view controller containing it is released.

I don't think this is a stupid problem at my end - I spent a lot of time on my code, testing small bits at a time, taking countless heaps, ensuring that the mapView delegate is set to zero, etc., and in the end, this simple line:

self.mapView = [[MKMapView alloc] initWithFrame:CGRectMake(20, 3, 154, 171)]; 

allocates memory that accumulates by ~ 200KB each time I enter and exit the view controller in which mapView is located.

So my question is this: can anyone explain what is going on here? Is there a reason ARC doesn't release the memory occupied by my MKMapView? Is this a known issue? For me it looks a lot like a hold cycle, and quite a lot of memory is wasted, but it seems to me that this should be happening behind the scenes ...

EDIT

Here is the property declaration for my mapView :

 @property (nonatomic, retain) MKMapView *mapView; 

Keep in mind that the only thing I do with this MKMapView is alloc and init, as seen from the line of my original question (of course, I would like to do more with this kind of map, but I narrowed it down to this line, being the only one the part that causes the leak - mapView never inserted into the view). When I comment on this single line, the leak will disappear.

+4
source share

All Articles