Note that there are some explanatory texts on larger screens.

plurals
  1. POHuge Memory Leak in CGMutablePathRef
    primarykey
    data
    text
    <p>I Have Rendered nearly 1000 Polygons in the map. I get the path of the polygon using</p> <pre><code>- (CGPathRef)polyPath:(MKPolygon *)polygon { MKMapPoint *points = [polygon points]; NSUInteger pointCount = [polygon pointCount]; NSUInteger i; if (pointCount &lt; 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 &lt; 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); } } } </code></pre> <p>I get leak in </p> <pre><code>CGPathRelease(interiorPath); </code></pre> <p>and</p> <pre><code>return path; </code></pre> <p>I know that i have to release path using CGPathRelease but where to release it while i have to return.</p> <p>Both leaks a huge memory. I have been working on this for days, Please help.</p> <p>Thanks in Advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload