MKMapSnapshotter uses incredible amounts of CPU & RAM

笑着哭i 提交于 2019-12-09 15:12:15

问题


MKMapSnapshotter seems to use up to 2GB of RAM when in the simulator, and triggers memory warnings and hangs my app for a very long time on the device. I'm not sure what part of my settings is causing this.

This huge usage occurs when retrieving multiple image simultaneously, but even retrieving multiple images one after the other seems to use frankly huge amounts of RAM, 600MB at peak, and fully occupies the CPU, using up to 190%. I've tried removing all other logic, not even saving the images after they're requested, and the huge RAM & CPU usage still occurs.

This cannot be intended. There must be something I'm not setting, to cause this runaway resource hogging. Here's my options code:

    MKMapSnapshotOptions* options = [MKMapSnapshotOptions new];
    options.region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(self.lat.doubleValue, self.lng.doubleValue), MKCoordinateSpanMake(0.01, 0.01));
    options.scale = 2.0;
    options.size = CGSizeMake(300, 44);
    options.showsBuildings = NO;

    MKMapSnapshotter* snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
    [snapshotter startWithCompletionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
        // even if I do nothing in here, it still goes crazy
    }];

What am I missing here?

来源:https://stackoverflow.com/questions/24994232/mkmapsnapshotter-uses-incredible-amounts-of-cpu-ram

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