How to fix the excess memory being used in mapKit Ios ?

我怕爱的太早我们不能终老 提交于 2019-12-12 05:53:59

问题


Im using a mapKit , drag dropped it from story board. initially the memory use is 30.3mb but as soon as the map is loaded it jumps to 150 and stars increases to as much as 500mb .I tried implementing the hotFix mentioned.

- (void)applyMapViewMemoryHotFix{

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

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

            break;
        default:
            break;
    }

    [self.mkMapView removeFromSuperview];
    self.mkMapView = nil;
} 

It did nothing. I called this method both in did and will disappear with no change . :( please help, stuck with this for more than a day now. Initially asked by some dude here iOS6 MKMapView using a ton of memory, to the point of crashing the app, anyone else notice this?. Im using IOS8.1


回答1:


MapKit does something that is incredibly memory-intensive. It downloads tons of tiles of map image data (at multiple scales) and caches them in memory so you can scroll around and see the map regions you visited before without re-downloading.

The fact that it uses 500+ mb of memory is fine. It is finely tuned to use lots of memory in order to give the best user experience, without running out of memory and crashing.

Running an app with an embedded map view does cause your app to be under a fair amount of memory pressure, but that's ok. You need to write your app with good memory management. (no memory leaks, only keep those things in memory that you can't recreate/re-load from disk, etc. You also need to code your app to handle memory warnings.) If you are crashing it's because YOUR code has memory problems, not MapKit.

I suggest you run static analysis on your program to look for memory leaks, and then also run it under the Leaks Instrument and the Allocations Instrument. Both static analysis and Instruments are important tools that you need to learn how to use.



来源:https://stackoverflow.com/questions/35700726/how-to-fix-the-excess-memory-being-used-in-mapkit-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!