iOS6 MKMapView using a ton of memory, to the point

2019-01-03 23:30发布

Has anyone else, who's using maps in their iOS 6 apps, noticing extremely high memory use to the point of receiving memory warnings over and over to the point of crashing the app?

I've ran the app through instruments and I'm not seeing any leaks and until the map view is created the app consistently runs at around ~3mb Live Bytes. Once the map is created and the tiles are downloaded the Live Bytes jumps up to ~13mb Live Bytes. Then as I move the map around and zoom in and out the Live Bytes continuos to climb until the app crashes at around ~40mb Live Bytes. This is on an iPhone 4 by the way. On an iPod touch it crashes even earlier.

I am reusing annotation views properly and nothing is leaking. Is anyone else seeing this same high memory usage with the new iOS 6 maps? Also, does anyone have a solution?

12条回答
一夜七次
2楼-- · 2019-01-03 23:51

My footprint was: 2.48; 19.51; 49.64; 12.60 which is: Memory before loading the mapView, after loading the mapView, after zooming in/out a bit, and after releasing the mapView (which is quite annoying, even after releasing the mapView, I keep 10MB increment and it doesn't go down!)

Anyway, I am not using an IBOutlet for the MapView anymore, I am creating everything in code instead. The new footprint is now: 2.48; 19.48; 38.42; 12.54.

Still working on putting the bi*** down.

查看更多
老娘就宠你
3楼-- · 2019-01-03 23:52

I experience the same issue.

Memory is never released after zoom and change location.

The only trick i've found is to change map type after memory warning.

查看更多
戒情不戒烟
4楼-- · 2019-01-03 23:53

I'm receiving same issue -

I'm not entirely sure about this, but could it be that the new apple maps preloads a huge area of the map to cater for offline navigation?

If you turn your connection off after the map has loaded, then try and zoom in on areas nowhere near the desired location then there seems to be an awful lot of detail still available.

查看更多
祖国的老花朵
5楼-- · 2019-01-03 23:54

For those journerying here in 2014+ (iOS8 and up)

I am running into this problem on iOS 7+ trying to support older devices (think Ipad 2 with 512MB).

My solution is to disable Zoom as it easily takes the most memory.

   long mem = [NSProcessInfo processInfo].physicalMemory;
    if(mem < _memory_threshold){
        self.MapView.zoomEnabled = NO;
    }

I have tried everything from switching map types, to deallocating the map, setting the delegate to nil, removing all overlays, annotations etc.

None of that works on iOS7+. In fact, most of these fixes cause jumps in memory, as MKMapView seems to leak and never properly dealloc (I have verified through sub-classing that I see dealloc hit).

This sucks, but all I have came up with so far is disabling map features (zoom, scroll, user interactions) as a means to limit the atrocious amount of memory MKMapView takes. This has resulted in my App at the very least being semi-stable on older devices.

查看更多
Melony?
6楼-- · 2019-01-03 23:58

Not sure about the consequences.

How ever setting map to 'nil' whenever view disappears, helped me to reduce memory usage from ~250MB to ~50-60MB.

-(void)viewDidDisappear:(BOOL)animated
{
     self.map = nil; 
}
查看更多
我想做一个坏孩纸
7楼-- · 2019-01-03 23:59
- (void)applyMapViewMemoryHotFix{

    switch (self.mapView.mapType) {
        case MKMapTypeHybrid:
        {
            self.mapView.mapType = MKMapTypeStandard;
        }

            break;
        case MKMapTypeStandard:
        {
            self.mapView.mapType = MKMapTypeHybrid;
        }

            break;
        default:
            break;
    }


    self.mapView.mapType = MKMapTypeStandard;



}
-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
    [self applyMapViewMemoryHotFix];
}
查看更多
登录 后发表回答