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

  • SEARCH
  • Home
  • 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 3351812
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:57:14+00:00 2026-05-18T01:57:14+00:00

I Have Rendered nearly 1000 Polygons in the map. I get the path of

  • 0

I Have Rendered nearly 1000 Polygons in the map. I get the path of the polygon using

-   (CGPathRef)polyPath:(MKPolygon *)polygon
{
     MKMapPoint *points = [polygon points];
     NSUInteger pointCount = [polygon pointCount];
     NSUInteger i;
     if (pointCount < 3)
         return NULL;
     CGMutablePathRef path = CGPathCreateMutable();
     if([polygon isKindOfClass:[MKPolygon class]])
     {
            for (MKPolygon *interiorPolygon in polygon.interiorPolygons)
      {
       CGPathRef interiorPath = [self polyPath:interiorPolygon];
       CGPathAddPath(path, NULL, interiorPath);
       CGPathRelease(interiorPath);
       }
  }
     CGPoint relativePoint = [self pointForMapPoint:points[0]];
     CGPathMoveToPoint(path, NULL, relativePoint.x, relativePoint.y);
     for (i = 1; i < pointCount; i++) 
     {
            relativePoint = [self pointForMapPoint:points[i]];
            CGPathAddLineToPoint(path, NULL, relativePoint.x, relativePoint.y);
     }
     return path;
}

- (void)drawMapRect:(MKMapRect)mapRect
      zoomScale:(MKZoomScale)zoomScale
      inContext:(CGContextRef)context
{
    MultiPolygon *multiPolygon = (MultiPolygon *)self.overlay;
for (MKPolygon *polygon in multiPolygon.polygons) 
{
    if([polygon isKindOfClass:[MKPolygon class]])
    {
            CGPathRef path = [self polyPath:polygon];
            if (path) 
            {
                [self applyFillPropertiesToContext:context atZoomScale:zoomScale];
                CGContextBeginPath(context);
                CGContextAddPath(context, path);
                CGContextDrawPath(context, kCGPathEOFill);
                [self applyStrokePropertiesToContext:context atZoomScale:zoomScale];
                CGContextBeginPath(context);
                CGContextAddPath(context, path);
                CGContextSetAlpha(context,1.0);
                CGContextStrokePath(context);
            }
            CGPathRelease(path);
    }
}
}

I get leak in

CGPathRelease(interiorPath);

and

return path;

I know that i have to release path using CGPathRelease but where to release it while i have to return.

Both leaks a huge memory.
I have been working on this for days, Please help.

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-05-18T01:57:15+00:00Added an answer on May 18, 2026 at 1:57 am

    You should rename your method to be -createPolyPath: to make it clear that it is returning a Core Foundation object that needs to be released, then in the code in which you call -createPolyPath:, you need to release it like so:

    CGPathRef path = [someObjectOrClass createPolyPath:somePolygon];
    // Do some stuff with the path
    CGPathRelease(path);
    

    See the “Memory Management Programming Guide for Core Foundation”:

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

Sidebar

Related Questions

I have rendered a hidden column using the fnRender function like this aTargets: [0],
I have successfully rendered my test report using Winforms.ReportViewer in WPF app.... Now I
I have rendered one of my controls into a string. I want to safely
I have an html table rendered page and I want to save it as
I have a page which needs to be rendered in Quirks mode for the
A have a ListView that is rendered with multiple items. Now I want to
I have some squares s of size 15px rendered on a page. Their absolute
We have bunch of Domain Entities which should be rendered to an html format,
Suppose I have an action that returns an rendered asp.net mvc control and send
I have created styled a ListBox in WPF so that it is rendered as

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.