简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM