使用Google Maps SDK for iOS时,内存和CPU使用率非常高 [英] Very high memory and CPU usage when using Google Maps SDK for iOS

查看:424
本文介绍了使用Google Maps SDK for iOS时,内存和CPU使用率非常高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,我必须在地图上显示注册用户。我必须显示他们的个人资料照片。可能有很多,可能是1000,2000或3000.

问题是,通过添加每个图像,其内存使用量增加,应用程序变慢。例如,我正在使用这段代码:

  UIImageView * imgView = imgView = [[UIImageView alloc] initWithImage:[ UIImage imageNamed:@like_r.png]]; 
for(int i = 0; i <1000; i ++)
{
GMSMarker * marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(31.4514885,74.2642593);
marker.iconView = imgView;
marker.map = _mapView;
}

有没有一种很好的方式显示地图上的所有用户?

解决方案

尝试设置 marker.tracksViewChanges = NO; 以允许CPU闲置。

或者,设置 marker.image = [UIImage imageNamed:@like_r.png]; ,而不是设置iconView,它应该有类似的效果。



这些改变应该有助于CPU,但可能无法解决内存相关的问题。


I am creating an app in which I have to show the registered users on the map. I have to display their profile pictures. There can be many of them, may be 1000, 2000, or 3000.

The problem is, by adding every image, its memory usage increases and the app slows down. For example, I am using just this piece of code:

UIImageView * imgView = imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"like_r.png"]];
for(int i=0;i<1000;i++)
{
    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(31.4514885, 74.2642593);
    marker.iconView = imgView;
    marker.map=_mapView;
}

Is there a good way to show all users on the map?

解决方案

Try setting marker.tracksViewChanges = NO; to allow the CPU to idle.

Alternatively, set marker.image = [UIImage imageNamed:@"like_r.png"]; instead of setting the iconView, which should have a similar effect.

These changes should help with CPU, but may not solve the memory-related issues.

这篇关于使用Google Maps SDK for iOS时,内存和CPU使用率非常高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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