如何修复mapKit Ios中使用的多余内存? [英] How to fix the excess memory being used in mapKit Ios ?

查看:90
本文介绍了如何修复mapKit Ios中使用的多余内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mapKit,将其从故事板上拖放.最初,内存使用量为30.3mb,但是一旦加载地图,它就会跳到150mb,星星增加到500mb.我尝试实现提到的hotFix.

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;
} 

它什么也没做.我在do中都调用了此方法,并且将保持不变而消失. :(请帮忙,现在已经坚持了一天以上. 最初由某人在这里问

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所做的事情占用大量内存.它会下载成吨的地图图像数据块(以多种比例)并将其缓存在内存中,因此您可以滚动浏览并查看之前访问过的地图区域,而无需重新下载.

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.

使用500 mb以上的内存这一事实很好.我们对其进行了微调,以使用大量内存以提供最佳的用户体验,而不会耗尽内存并避免崩溃.

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.

运行具有嵌入式地图视图的应用程序确实会导致您的应用程序承受相当大的内存压力,但这没关系.您需要使用良好的内存管理来编写您的应用程序. (没有内存泄漏,仅将那些您无法从磁盘重新创建/重新加载的内容保存在内存中,等等.您还需要对应用程序进行编码以处理内存警告.)如果崩溃,是因为您的代码存在内存问题,而不是MapKit.

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.

这篇关于如何修复mapKit Ios中使用的多余内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆