4

I have a MKMapView managed in certain UIViewController. This view controller is pushed/popped from a UINavigationController. When running the app with Xcode's Intruments to see the memory allocations and look for leaks, I find that, starting from a certain Live Bytes value, when I navigate to such view controller with a map view, and then I navigate back, the view controller is deallocated but the Live Bytes value I had before navigating forth is always incremented more or less the same amount of bytes.

I've navigated forth and back from the view controller with the map several times in a row to show you the values: the screenshots were taken once navigated back from the view controller.

first time back

second time back

third time back

I "nilify" all view controller's views and subviews in viewDidUnload delegate method, and I also "nilify" strong properties and remove map's annotations and overlays in viewWillDisappear:. What could be causing that increment in Live Bytes every time I navigate back from this view controller? Is it because of the map view itself?

The screenshots are from a device running iOS 6.1

Thanks in advance

EDIT: the leaks graph in Instruments is "clean":

leaks

EDIT 2: I've tested the same scenario in a device running iOS 7.1 and I don't see the increment in Live Bytes when navigating back. It seems to be an issue related to iOS 6, and I found some posts dealing with it:

How to resolve the memory issue with Map on iOS 6

MKMapView memory usage steadily increasing

However, I don't find a solution, is it actually an iOS 6.X bug?

EDIT 3: I tried the following solutions, but still get the same values in Instruments:

I don't get any memory warning, though.

Community
  • 1
  • 1
AppsDev
  • 12,319
  • 23
  • 93
  • 186
  • ... and what did the leaks tool tell you? Not your own guesswork based on one metric in isolation, the actual tool? – Tommy Jul 07 '14 at 18:06
  • @Tommy the leaks graph does not show any peak... – AppsDev Jul 07 '14 at 18:08
  • Living bytes = the number of objects created and still residing on the heap. So top options are: (i) `MKMapView`s caching adds up, and isn't obliged to work how you or I would guess; and, less likely (ii) the relevant objects aren't actually leaked — there's a reference somewhere to something deep that you're missing. But that'd normally be from some manual view manipulation that doesn't work correctly or adding something to a more-global data store and forgetting to remove it. – Tommy Jul 07 '14 at 18:19
  • 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) – The dude Jul 08 '14 at 08:13
  • @Thedude not exactly, I think... this post complains about the memory usage while using the map view. The issue I find is the memory increment when the map view is not shown anymore... – AppsDev Jul 08 '14 at 08:29
  • Sorry, my fault, duplicate of http://stackoverflow.com/questions/16420018/memory-not-being-released-for-mkmapview-w-arc – The dude Jul 08 '14 at 13:01
  • @Thedude Thanks. I tried that solution and it doesn't work for me... – AppsDev Jul 08 '14 at 15:21
  • Did you find an answer? Still an issue in iOS 9. Segue to and from a map view eventually crashes due to memory warning. – DogCoffee Sep 06 '15 at 09:50

0 Answers0