0

I have 2 viewControllers: The first one is the mainViewController that sends after pressing a button to the second viewController with a Push method, the second viewController has a mapView that shows my position. The problem is that the first time I start the app the memory used by the mainViewController is near 15mb but after switching to the second viewController and pressing the back button in order to go back to mainViewController the memory used it's near 40mb, I'm using storyboards and arc does anyone have a solution for this?

LS_
  • 6,763
  • 9
  • 52
  • 88
  • possible duplicate of [iOS6 MKMapView using a ton of memory, to the point of crashing the app, anyone else notice this?](http://stackoverflow.com/questions/12641658/ios6-mkmapview-using-a-ton-of-memory-to-the-point-of-crashing-the-app-anyone-e) – Milo Jul 22 '14 at 10:21
  • Already checked that post but without luck.. I tried the solution posted but it doesn't release the memory – LS_ Jul 22 '14 at 10:26
  • Perhaps switch to Google Maps? – Milo Jul 22 '14 at 10:26
  • If no one has a solution for this I think i'll have to – LS_ Jul 22 '14 at 10:31
  • Out of interest, does the Leaks Instrument actually show that the memory is objects that are no longer referenced and reachable or are reference cycles? Also be aware that if you're running in debug mode and have NSZombies enabled memory may not be reclaimed as quickly as in release mode. – Robotic Cat Jul 22 '14 at 11:48

1 Answers1

0

Try this in your viewWillDisappear:(BOOL)animated method in your second view controller, the one with the map:

mapView.showsUserLocation = NO;
mapView.delegate = nil;
[mapView removeFromSuperview];
mapView = nil;
Milo
  • 5,041
  • 7
  • 33
  • 59
  • Tried it but I still have the memory leak.. Thanks for the help anyways :) – LS_ Jul 22 '14 at 10:40
  • @Signo yeah, MKMapView is very memory intensive and has many leaks. Luckily if you do have a memory warning, Apple handles the map view very nicely so your app won't crash as long as you do everything you can to keep it low. – Milo Jul 22 '14 at 10:41
  • ye, even if it's very annoying I think I'll have to adapt to these "leaks", maybe I'll try to implement google maps as you suggested before, again thanks for your time! :) – LS_ Jul 22 '14 at 10:49