Skip to content
This repository was archived by the owner on Aug 25, 2023. It is now read-only.
This repository was archived by the owner on Aug 25, 2023. It is now read-only.

Memory Issue with MBXMapViewTileOverlay? #30

Closed

Description

@jrmatchett

My app has a view controller for presenting an MBXMapView. The view is defined using a XIB that contains a main view and an MBXMapView-class subview. The MBXMapView view's referencing outlet and delegate are set to the view controller. Here's the view controller's interface:

#import "MBXMapKit.h"
@interface XYZMapViewController : UIViewController <MKMapViewDelegate>
@property (weak, nonatomic) IBOutlet MBXMapView *mapView;
@end

and in the implementation file I set the map view’s mapID in the viewDidLoad method:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.mapView.mapID = @"justin.map-pgygbwdm";
}

It’s a navigation controller-based app, so I present the map to the user by pushing the map view controller onto the navigation stack. The map correctly appears and displays the online tiles; however, after pushing and popping the controller several times, app memory seems to be accumulating. Monitoring the allocations in Instruments, there are 2 MBXMapViewTileOverlay objects created each time the map view controller is created, one by -[MBXMapView MBXMapView_commonSetupWithMapID:showDefaultBaseLayerMode:] and one by __27-[MBXMapView updateOverlay]_block_invoke_2. When the map view controller is popped and deallocated, the 2 MBXMapViewTileOverlay objects remain in memory. In the code I don’t immediately see what might be holding a strong reference to them. Is this a bug, or am I not creating the map view properly? Thanks!

Activity

  1. jrmatchett commented on Feb 4, 2014

    @jrmatchett
    Author

    Thanks. Regarding setting the delegate, the example I gave above was a minimal one to demonstrate the bug, and my actual map view controller needs to respond to updates in user location and interactions with map annotations. Actually, I need support for displaying offline tile sets, and discovered the bug while testing your fork adding support for MBTiles, which I was interested in since there are also some memory management issues in the Mapbox iOS SDK (e.g., mapbox/DEPRECATED-mapbox-ios-sdk#221). The advice about minimizing the number of map view allocations is good and I'm doing that to some extent already to improve performance, although not at the root level view controller. Thanks for your advice and hard work!

  2. incanus commented on Feb 18, 2014

    @incanus
    Contributor

    Thanks for the updates here. I'm going to close this for now as we work through some core issues in the way that the main "overlay" is done and eventually possibly add support for additional overlays. Let's let the dust settle a bit and then profile/static analyze/check this again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions