1

I am working on a application that demands users to show on the map like, when user register in to the application he/she upload its picture, when sending picture to server along with picture I scale the image to 0.1 so that its size could be reduced. The thing is I have to show the user image like this is the base image on which user picture will be pasted

The code to paste user image to this marker I used the code`

-(UIImage*) drawImage: (UIImage*) fgImage
          inImage:(UIImage*) bgImage
          atPoint:(CGPoint)  point
{  
        UIGraphicsBeginImageContextWithOptions(bgImage.size, FALSE, 0.0);
        [bgImage drawInRect:CGRectMake( 0, 0, bgImage.size.width, bgImage.size.height)];
        [fgImage drawInRect:CGRectMake( point.x, point.y, fgImage.size.width, fgImage.size.height)];
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();   
        return newImage;
}

fgImage is user pic image and bgImage is base image. this fuction returns me the complete image with green marker and rounded user image pasted on it. After that I pass this image to Map Marker

 marker.icon =  [self drawImage:[self makeRoundedImage:img radius:25] inImage:markerImage atPoint:CGPointMake((markerImage.size.width/2)-25, (markerImage.size.width/2)-25)];

The problem I am facing is I have created 70 testing users and App memory grows to 100 MB with so many custom markers on it. Please suggest me the best solution to handle this situation . Thanks.

MrUpsidown
  • 21,592
  • 15
  • 77
  • 131
Hassan Malik
  • 559
  • 6
  • 20

1 Answers1

0

If multiple markers use the same image, make sure that they are reference the same object not multiple instances of the same content. You can also check the solution for this issue.

Also check this SO question for more information.

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31