title: Unloading MKMapView after pop from Navigation Controller
body: <p>I have 2 view controllers, first one, named <code>InitialVC</code>, containing a <code>UIButton</code> which pushes the 2nd view controller when clicked. <code>InitialVC</code> is embedded in <code>UINavigationController</code>.</p>
  
  <p>The second view controller is <code>MapVC</code>, which contains a <code>MKMapView</code> and a back button. </p>
  
  <p>When <code>InitialVC</code> is loaded, memory usage is <strong>30MB</strong>. Then when it is pushed into <code>MapVC</code>, memory usage jumps to <strong>100MB</strong>. When I press the back button to navigate back to <code>InitialVC</code>, the memory usage is still <strong>100MB</strong>. </p>
  
  <p><em>That means, <code>MKMapView</code> is still running in the background.</em></p>
  
  <p>I don't want this, which will definitely cause performance issues. I understand that by default, the <code>MKMapView</code> will unload once memory warning is issued ( in <code>didReceiveMemoryWarning</code> ), but <strong>my question is</strong>, is it a good practice to dealloc the <code>MKMapView</code> in <code>viewWillDisappear</code> / <code>viewDidUnload</code> / <code>viewDidDisappear</code> / <code>viewWillUnload</code> etc ? or is there any better to control the memory usage ?</p>
  
  <p>If you need codes, here it is (nothing special):</p>
  
  <p><strong>InitialVC.m</strong></p>
  
  <pre><code>- (IBAction)clickMap:(id)sender {
    MapVC *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MapVC"];
    [self.navigationController pushViewController:vc animated:YES];
  }
  </code></pre>
  
  <p><strong>MapVC.m</strong></p>
  
  <pre><code>@interface MapVC {
    IBOutlet MKMapView *map_view;
  }
  @end
  
  - (IBAction)clickBack:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
  }
  </code></pre>
  
  <p>I didn't setup a <code>@property</code> for <code>MKMapView</code>, as it is not used in other classes.</p>
  
  <p>Additional information:</p>
  
  <ul>
  <li>Using ARC</li>
  <li>Using Storyboard</li>
  <li>Using iOS 7 SDK</li>
  <li>Using Xcode 5.x</li>
  </ul>
  
  <p><em>Note: this question may apply to cases other than <code>MKMapView</code> too.</em></p>
  
  <hr>
  
  <p><em>Update:</em></p>
  
  <p>After changing the strong reference in <code>@interface</code> to:</p>
  
  <pre><code>@property (nonatomic, weak) IBOutlet MKMapView *map_view;
  </code></pre>
  
  <p>The memory pattern is now:</p>
  
  <ul>
  <li>Loaded <code>InitialVC</code>: <strong>30MB</strong></li>
  <li>Push into <code>MapVC</code>: <strong>100MB</strong></li>
  <li>Pop back to <code>InitialVC</code>: <strong>90MB</strong></li>
  <li>Push into <code>MapVC</code>: <strong>100MB</strong></li>
  <li>Pop back to <code>InitialVC</code>: <strong>90MB</strong></li>
  </ul>
  
  <p>The memory issue is slightly relieved.</p>
  
  <hr>
  
  <p><em>Update 2:</em></p>
  
  <p>dealloc test is performed; <code>- (void)dealloc</code> didn't get called</p>
  
  <hr>
  
  <p><em>Update 3:</em></p>
  
  <p>There is a <code>MKMapViewDelegate</code> connected, and a non-repeating <code>NSTimer</code> event which triggers when user drags the map. There is also a <code>AFNetworking</code> 2 block-based notification in the <code>NSTimer</code> event, which fetches data from server and update the annotations on the map. Note: The server response completed successfully.</p>