2

So i have a UIScrollView with UIPageControl which has a bunch of MKMapViews (mostly 15 different maps). The app is really sluggish once this view loads and after a few minutes of usage i get a memory warning. I looked at it in Instruments and the maps take an insanely high chunk of memory. Even upto ~200mb sometimes. One thing i can think of is to reuse the mapViews. But because of how the views are structured the coding complexity increases. Any suggestions how i can improve performance?

This is how my app is structured:

I have a view controller which has a UIScrollView which i use for horizontal scrolling. In the scrollView i read subviews from an array of view controllers which contains the mkmapview.

Hope that made sense! I used Apple's pageControl sample app as a point of reference while coding so the design is roughly similar.

Thanks in advance!

EDIT: So i tried adding a single instance of the mapView and changing the coordinates on swiping. It still takes a decent amount of memory.

Sohan
  • 1,287
  • 1
  • 15
  • 29
  • the mkmapview in ios6 is not manageable in terms of memory usage IMO :: see http://stackoverflow.com/questions/15701990/mkmapview-memory-issue-in-ios-6-0-or-later/15702093#15702093 – Daij-Djan Mar 29 '13 at 11:17

1 Answers1

0

To scroll through an arbitrary number of pages in a scroll view you only need two content views, not 15. That's because there'll never be more than two content views visible at any given time. You can re-layout your content in the UIScrollView delegate's -scrollViewDidScroll: method.

gcbrueckmann
  • 2,413
  • 18
  • 10
  • But the mapView is what's causing the memory warnings. If i don't add the mapView the scrolling and performance of the app is just fine. – Sohan Aug 16 '12 at 09:35
  • I doubt using a single map view will cause you serious resource problems. Hundreds of apps are using this class. Also, memory warnings aren't necessarily a problem as long as they're handled properly, i.e. you should release any unneeded resources. – gcbrueckmann Aug 16 '12 at 21:44
  • In that case i'm probably doing something catastrophically wrong elsewhere :) will check. Thanks! – Sohan Aug 17 '12 at 11:00
  • 6
    I'm experiencing a similar problem but I've already identified the cause. The iOS 6 MKMapView is taking 10x more memory than the previous one. My App is all about showing stuffs on maps and its footprint increased from 30MB to 280MB. I'm trying to solve it, but no clue yet. – Trein Oct 05 '12 at 03:42
  • @KevinBallard: I haven't found a permanent solution yet. I'm currently using a very ugly workaround that looks like this https://gist.github.com/trein/ca47ad34dff041cfb9fb. – Trein Jan 17 '15 at 15:53