Results 1 to 8 of 8

Thread: iOS. Big memory usage after adding many annotations

  1. #1
    Neuer skobbler
    Join Date
    13.11.2015
    Posts
    5

    Ausrufezeichen iOS. Big memory usage after adding many annotations

    Hello, i have installed SDK via Cocoapods, there are error in file SKRoutingservice.h

    SDK trying to call function
    Code:
    -(void)zoomToRouteWithInsets:(UIEdgeInsets)insets;
    but there are no such function, only
    Code:
    -(void)zoomToRouteWithInsets:(UIEdgeInsets)insets duration:(int)duration;
    available, so it won't compile. But it's not a main problem.

    1) My task is to add custom annotations with custom views on map. How i do these see code below.

    i'm trying to add 457 annotations. Device iPhone 5 simulator, iOS 8
    Code:
    for (NSUInteger i = 0; i<[self.fetchedResultController fetchedObjects].count; ++i) {
            LandmarksPOI *landmark = [[self.fetchedResultController fetchedObjects] objectAtIndex:i];
            SKAnnotation *annotation = [SKAnnotation annotation];
            UIImageView *pinView = [[UIImageView alloc] init];
            pinView.frame = CGRectMake(0, 0, 37, 66);
            pinView.image = [UIImage imageNamed:@"pin_g"];
            SKAnnotationView *view = [[SKAnnotationView alloc] initWithView:pinView reuseIdentifier:@"uniId"];
            annotation.annotationView = view;
            annotation.identifier = [landmark.theId integerValue];
            annotation.location = CLLocationCoordinate2DMake([landmark.address.latitude floatValue], [landmark.address.longitude floatValue]);
            [self.mapView addAnnotation:annotation withAnimationSettings:[SKAnimationSettings animationSettings]];
        }
    After i add all annotations my app start using 516-518 mb of memory, or it's crash on device. What i'm doing wrong?
    2) And how to group annotations when i zoom out map?

    Thank you.
    Last edited by Hibari; 14.11.2015 at 10:17.

  2. #2
    Neuer skobbler
    Join Date
    13.11.2015
    Posts
    5
    okay, problem is in SKAnnotationView, if i don't set custom view my app use only ~200mb, not good but better then was, so how can i set custom annotation view without big memory usage?

  3. #3
    Neuer skobbler
    Join Date
    13.11.2015
    Posts
    5
    Magic, i optimise my code a little bit:

    Code:
        UIImageView *pinView = [[UIImageView alloc] init];
        pinView.frame = CGRectMake(0, 0, 28, 50);
        pinView.image = [UIImage imageNamed:@"pin_g"];
        SKAnnotationView *view = [[SKAnnotationView alloc] initWithView:pinView reuseIdentifier:@"viewID"];
        for (NSUInteger i = 0; i<[self.fetchedResultController fetchedObjects].count; ++i) {
            LandmarksPOI *landmark = [[self.fetchedResultController fetchedObjects] objectAtIndex:i];
            SKAnnotation *annotation = [SKAnnotation annotation];
            annotation.annotationView = view;
            annotation.annotationType = SKAnnotationTypeGreen;
            annotation.identifier = [landmark.theId integerValue];
            annotation.location = CLLocationCoordinate2DMake([landmark.address.latitude floatValue], [landmark.address.longitude floatValue]);
            [self.mapView addAnnotation:annotation withAnimationSettings:nil];
        }
    all changes are useless, except of
    Code:
    pinView.frame = CGRectMake(0, 0, 28, 50);
    when i change image size memory usage decreased to 250 mb, still bad, help please

  4. #4
    Etablierter skobbler
    Join Date
    26.10.2015
    Posts
    36
    The subject title says big memory usage after adding many annotations.

    1. How many annotations are you adding?
    2. How much memory usage is there if you comment out the code that creates and adds the annotations?

    That info might help provide some perspective to the problem.

  5. #5
    Neuer skobbler
    Join Date
    13.11.2015
    Posts
    5
    I update my post.
    I'm trying to add 457 annotations now, but it may be more.
    457 - use 516 mb with pinView size (37, 66)
    457 - use 250 mb with pinView size (28, 50)

    Thank you.

  6. #6
    Etablierter skobbler
    Join Date
    26.10.2015
    Posts
    36
    Do you know the memory usage if you comment out the code the creates and adds the annotations? What's the memory usage if you add 228 (half of 457) annotations?

    I'm just wondering about the impact on memory of the annotations vs. the rest of the program.

  7. #7
    Neuer skobbler
    Join Date
    13.11.2015
    Posts
    5
    I'm also wondering about such usage i don't have any leaks, app without map use ~40mb, when i initialise map with API key in appDelegate memory usage grows to ~60mb, when i open controller with map and without annotations memory usage grows to ~170 mb.

  8. #8
    Etablierter skobbler
    Join Date
    26.10.2015
    Posts
    36
    Interesting. I'm seeing high memory usage also. When running on a iPad retina simulator, I see around 20MB increase when I had a pair of annotations (1 image--a pin, and one uiview). When I run on an iPad 2 simulator, I see about 4MB increase.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •