2

Whenever MKMapView is initialised and set to a location

- (void) setMapLocationItem:(Location*)geofence{

    if(self.mapView==nil){
        self.mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
        [self.mapView setDelegate:self];
        [self.view addSubview:self.mapView];
        [self.view sendSubviewToBack:self.mapView];
        [self.view sendSubviewToBack:self.collectionView];
    }
    [self.mapView setHidden:NO];
    [_mapView removeAnnotations:_mapView.annotations];
    CLLocationCoordinate2D coordinate;

        coordinate= CLLocationCoordinate2DMake(geofence.latitude.doubleValue, geofence.longitude.doubleValue);

    CGFloat radius = 110;
    if([geofence.radius boolValue])
        radius = [geofence.radius floatValue];
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance (coordinate, radius, radius);
    [_mapView setRegion:region animated:NO];

    self.annotation = [[MKPointAnnotation alloc] init];
    self.annotation.coordinate = coordinate;
    self.annotation.title = geofence.name;
    self.annotation.subtitle = geofence.address;
    [_mapView addAnnotation:self.annotation];
}

The memory used my the map is never released whenever the viewController is closed.

Its is only getting released when another MKMapView is initialized. Any thoughts as too why this is? I have referred the solutions in this question iOS6 MKMapView Memory Issue

Community
  • 1
  • 1
Edwin Abraham
  • 645
  • 7
  • 24
  • The memory leak profiler tool should tell you if it's your responsibility or Apple's – SomeGuy Jan 19 '15 at 10:31
  • 1
    @SomeGuy what do you mean by that? It is pretty clear from the profiler that MKMapView is hoarding the memory for reuse. But the reason why its not released once _mapView = nil is the question. – Edwin Abraham Jan 19 '15 at 11:10

0 Answers0