Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Very high memory and CPU usage when using Google Maps SDK for iOS

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?

like image 644
Hassan Malik Avatar asked May 09 '16 13:05

Hassan Malik


1 Answers

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.

like image 96
Andrew Hershberger Avatar answered Oct 12 '22 02:10

Andrew Hershberger