hungio / route-me

Automatically exported from code.google.com/p/route-me
0 stars 0 forks source link

RMPath memory leak #49

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
-(void) dealloc
{
    CGPathRelease(path);

    [super dealloc];
}

...

Elsewhere in the object the instance variable "points" is created as an
array. This array is never released.

Furthermore, it doesn't appear to ever be used anywhere other than in one
method which just creates objects to put into the array. If it is never
accessed, it can most likely be deprecated and removed from the code.

The nasty method is as follows... the suggested fix is to strip out the
instance variable and everything that uses it.

- (void) addLineToXY: (RMXYPoint) point
{
//  NSLog(@"addLineToXY %f %f", point.x, point.y);

    NSValue* value = [NSValue value:&point withObjCType:@encode(RMXYPoint)];

    if (points == nil)
    {
        points = [[NSMutableArray alloc] init];
        [points addObject:value];
        origin = point;

        self.position = [[contents mercatorToScreenProjection] projectXYPoint:
origin];
//      NSLog(@"screen position set to %f %f", self.position.x, self.position.y);
        CGPathMoveToPoint(path, NULL, 0.0f, 0.0f);
    }
    else
    {
        [points addObject:value];
        point.x = point.x - origin.x;
        point.y = point.y - origin.y;
        CGPathAddLineToPoint(path, NULL, point.x, -point.y);

        [self recalculateGeometry];
    }
    [self setNeedsDisplay];
}

Original issue reported on code.google.com by dbx.gt...@gmail.com on 24 Feb 2009 at 5:27

GoogleCodeExporter commented 8 years ago
I'd like to leave the "points" ivar in the object for the time being, as its 
value is used (as a Boolean) to control path 
initialization. Elsewhere we have a patch that fixes the release. I think 
there's room for enhancement of the 
RMPath to handle subpaths and multiple path types, and when that work is 
started then "points" should go away.

Original comment by halmuel...@gmail.com on 1 Mar 2009 at 9:39