title: Memory not being released for MKMapView w/ ARC
body: <p>I have a custom <code>UIView</code> called <code>ActivityDetailView</code> that I instantiate and then add to a scrollview within a parent view controller.  When this custom view is allocated, it takes up about 1mb each time of additional memory and Instruments is showing that the memory is never being released even though the view and the parent view controller each have their <code>dealloc</code> methods being called.  I am getting memory warnings and the app is eventually getting killed so I'm obviously doing something wrong.</p>
  
  <p><strong>Updated w/ info about map view being the cause, but I need a fix</strong></p>
  
  <p>Within the custom <code>ActivityDetailView</code> nib file, there is a map view that is zoomed and centered around the users's location.  When I removed this map view from the nib so that it doesn't draw on screen, the memory allocation issues went away.  However, I obviously need the map view.  Why would the map view's data not be released when the map view goes out of scope?</p>
  
  <p>There is only 1 <code>ActivityDetailView</code> and 1 <code>ActivityDetailViewController</code> alive when the view is showing.  As soon as I pop the view off the stack, they are no longer living.  Doesn't make sense how the memory keeps growing even though the objects are being killed as shown via Instruments.  If the parent views are deallocated, why isn't the map view data being deallocated?</p>
  
  <p>What am I doing wrong or what should I check?</p>
  
  <p>Here is the custom view:</p>
  
  <pre><code>@interface ActivityDetailView ()
  {
      CLLocation *location;
      __weak id parentViewController;
      int scrollViewX;
  
      ImageUtility *imageUtility;
  }
  @end
  
  @implementation ActivityDetailView
  
  -(id)initWithFrame:(CGRect)frame
  {
      self = [super initWithFrame:frame];
      if (self)
      {
          NSArray *xibViews = [[NSBundle mainBundle] loadNibNamed:@"ActivityDetailView" owner:nil options:nil];
          if ([xibViews count] &lt; 1) return nil;
          ActivityDetailView * xibView = [xibViews objectAtIndex:0];
          [xibView setFrame:frame];
          self = xibView;
      }
      return self;
  }
  
  - (id)initWithLocation:(CLLocation *)loc parentController:(id)parent
  {
      self = [self initWithFrame:CGRectMake(0, 0, 320, 1000)];
      if (self)
      {
          imageUtility = [ImageUtility sharedManager];
  
          location = loc;
          parentViewController = parent;
          scrollViewX = 0;
  
          [self centerMapForActivityLocation];
          [self addPhotoButtonWithImageNamed:@"addActivityPhoto.png" target:parentViewController selector:@selector(addPhotoToActivity:)];
      }
      return self;
  }
  
  - (void)dealloc
  {
      NSLog(@"ActivityDetailView was dealloced");
  }
  </code></pre>
  
  <p>In the parent view controller:</p>
  
  <pre><code>@interface ActivityDetailViewController ()
  {
      ActivityDetailView *detailView;
  }
  @end
  
  @implementation ActivityDetailViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      // Some code left out for clarity
  
      [self setupView];
  }
  
  - (void)didReceiveMemoryWarning
  {
      NSLog(@"Purging image cache");
      [[ImageUtility sharedManager] purgeCache];
  }
  
  - (void)dealloc
  {
      // These essentially do nothing to help the problem
      detailView.mapView = nil;
      [detailView removeFromSuperview];
      detailView = nil;
      self.scrollView = nil;
  
      NSLog(@"ActivityDetailViewController was dealloced");
  }
  
  - (void)setupView
  {    
      // Add the activity detail view to the scroll view
      detailView = [[ActivityDetailView alloc] initWithLocation:self.activityLocation parentController:self];
      [self.scrollView addSubview:detailView];
      self.scrollView.contentSize = detailView.frame.size;
  
      // Setup the map view
      detailView.mapView.delegate = self;
      MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
      annotation.coordinate = self.activityLocation.coordinate;
      [detailView.mapView addAnnotation:annotation];
      if (self.activity.mapImageName) {
          detailView.mapView.scrollEnabled = YES;
          detailView.mapView.zoomEnabled = YES;
      } else {
          detailView.mapView.scrollEnabled = NO;
          detailView.mapView.zoomEnabled = NO;
      }
  
      // Add the weather area to the view
      dayView = [[DailyButtonView alloc] initWithFrame:CGRectMake(0, -17, 60, 70)];
      dayView.hidden = YES;
      [detailView.weatherView addSubview:dayView];
  }
  </code></pre>
  
  <p>Here's an image from Instruments showing that the majority of memory is from the nib loading</p>
  
  <p><img src="https://i.stack.imgur.com/UefRr.png" alt="Instruments screenshot"></p>
  
  <p>I don't have anything to cache at the moment. The view is basically a scrollview with a mapview inside of it and some labels and a couple of table views. The table views aren't populated with anything and I'm not loading any images within the view other than the background image for the scrollview, but that should get released when the view does.</p>