RMMapView not deallocating memory in iOS? This could be the problem

I’m working with Mapbox at the moment – it’s a great tool for bundling offline maps into your apps. I recently noticed that my RMMapView’s weren’t deallocating as expected. These map views used by Mapbox, I’m not sure if they’re open source or not. Anyway, long story short, this was leading to a memory leak and I spent about a day trying to figure out why. The fix is pretty simple, just remember to set the “showsUserLocation” flag to false when you destroy the parent view. Something like:

- (void)viewWillDisappear:(BOOL)animated {
    if ([self isMovingFromParentViewController]) {
        _mapView.showsUserLocation = NO;
    }
    [super viewWillDisappear:animated];
}

Hope this helps save someone a lot of time someday!

2 Comments RMMapView not deallocating memory in iOS? This could be the problem

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>