Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:04:12+00:00 2026-06-01T12:04:12+00:00

We have developed map base application. We have implemented multi-threading for display data on

  • 0

We have developed map base application. We have implemented multi-threading for display data on map view. While application is running longer(around 20 min), Application will display memory warning level-1. And after couple of minutes it will give memory warning level-2 and after level2 application will be crash or goes to sleep.

We have checked memory leaks, Zombies lot’s of time. But there is no memory leak and zombie in our application.

Please advice how to handle memory warning level. Please draw some line to overcome memory level warning.

////Update…
I found that memory usage increase because of

CGContextRef context = UIGraphicsGetCurrentContext();

I have used multithreading for draw poly-annotation and for that i used CGContextRef which increases my memory usage whenever i call it.

i don’t know how release context because if i release it than next time it shows me

Invalid Context error i am positing my drawing code here.Please help me if anybody have any idea.

-(void) drawRect:(CGRect)rect {
NVPolylineAnnotation* annotation = self.annotation;

CGFloat POLYLINE_WIDTH = 9;

if(annotation.getZoomLevel == 7) {
    POLYLINE_WIDTH = 1.5;
}
else if(annotation.getZoomLevel == 8) {
    POLYLINE_WIDTH = 2.5;
}
else if(annotation.getZoomLevel ==9) {
    POLYLINE_WIDTH = 3;   
}    
else if(annotation.getZoomLevel ==10) {
    POLYLINE_WIDTH = 3.4;   
}    
else if(annotation.getZoomLevel == 11) {
    POLYLINE_WIDTH = 4;
}    
else if(annotation.getZoomLevel <= 13) {
    POLYLINE_WIDTH = 4.3;
}
else if (annotation.getZoomLevel == 14) {
    POLYLINE_WIDTH = 5.4;
}
else if(annotation.getZoomLevel == 15) {
    POLYLINE_WIDTH = 8;
}


CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, rect);
CGContextSetLineWidth(context, POLYLINE_WIDTH);
CGContextSetAlpha(context, 0.6);    

for(NSDictionary *route in annotation.routes) {

    NSString *locations = [route valueForKey:@"Locations"];
    double speed = [[route valueForKey:@"Speed"] doubleValue];


    if (locations && ([locations length]/16 > 1)) {       

        UIColor *color;
        if (speed <= 20) {
            color = [UIColor colorWithRed:222/255.0 green:0/255.0 blue:0/255.0 alpha:1.0];
        }
        else if (speed <= 40) {
            color = [UIColor colorWithRed:253/255.0 green:91/255.0 blue:2/255.0 alpha:1.0];
        }
        else if (speed <= 60) {
            color = [UIColor colorWithRed:253/255.0 green:145/255.0 blue:4/255.0 alpha:1.0];
        }
        else if (speed <=80) {
            color = [UIColor colorWithRed:255/255.0 green:212/255.0 blue:4/255.0 alpha:1.0];
        }
        else if (speed >80) {
            color = [UIColor colorWithRed:42/255.0 green:176/255.0 blue:39/255.0 alpha:1.0];
        }

        CGContextSetStrokeColorWithColor(context, color.CGColor);

        for (int i = 0; i <= locations.length - 32; i += 32) {

            CLLocationCoordinate2D coordinates;
            coordinates.latitude = hexDecode([locations substringWithRange:NSMakeRange(i, 16)]);
            coordinates.longitude = hexDecode([locations substringWithRange:NSMakeRange(i+16, 16)]);

            CGPoint point = [_mapView convertCoordinate:coordinates toPointToView:self];

            if (i == 0)
                CGContextMoveToPoint(context, point.x, point.y);
            else
                CGContextAddLineToPoint(context, point.x, point.y);
        }
        [self setNeedsDisplay];
        CGContextStrokePath(context);

    }   
}   
context = NULL;
UIGraphicsEndImageContext();    

}

Thanks In Advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:04:13+00:00Added an answer on June 1, 2026 at 12:04 pm

    The first thing you need to do is measure your application to figure out where the memory growth is coming from. While you may have no leaks, you obviously have a memory growth problem. One tool that will help you identify where memory growth is coming from is the Allocations tools in Instruments. Specifically, you can use a technique called heapshot analysis to help narrow down what is causing the growth in your application. For more information, checkout this post on heapshot analysis.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed an application in which the data About Schools are stored in
I have created Map application for iPhone and I developed same Map application on
I have developed an application that shows one's location on a map. How do
I have developed an application on android.I have used Map overlay class in application.When
I have developed web map application using OpenLayers and GeoServer. Geoserver is installed on
I have developed the Google map application in android using Eclipse and AVD. Is
I have developed a window application in VS2005 using C#. I need to integrate
I have developed a few Delphi Win32 (currently using D2007) applications, which revolve around
I have developed a google map app and the zoom controls will not appear
I have developed an android application in which some OK button (soft key) is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.