Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKMapView memory issues in ios7 sdk

i have MKMapView in a view controller and when i starts zooming on it consume a lot of memory and when i leave the view who contains the MKMapView the memory is not released (I am using ARC in my App)

Edit:

i read in some stack overflow answers that i have to put the MKMapView in AppDelegate :

-(MKMapView*) mapView
{
    if(_mapView == nil) {
        _mapView = [[MKMapView alloc] init];
    }
    return _mapView;
}

and in viewWillDisappear of viewController that contains the MKMapView put

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    XAppDelegate.mapView.delegate = nil;
    [XAppDelegate.mapView removeFromSuperview];

}

but it did not resolve my problem.

like image 741
poyo fever. Avatar asked Feb 18 '14 17:02

poyo fever.


Video Answer


1 Answers

A common flaw I've seen is that the MKOverlay is holding a strong reference to the MKOverlayView/MKOverlayRender and the MKMapView. This causes a retain cycle because the MKMapView holds a strong reference to the MKOverlay instances as well.

like image 61
Holly Avatar answered Oct 17 '22 10:10

Holly