Question

I don't get it, how to solve the problem? I used "analyze" cause my program crashes due memory problems and the first one of seven similar notations is "Potential Leak of an Object stored into signalline" conected to CGContextStrokePath(signalContext);

- (void)drawHorizoLines{
for(int i = 1; i < self.frame.size.width/_sw;i++){
    CGContextRef signalContext = UIGraphicsGetCurrentContext();
    CGMutablePathRef signalLine = CGPathCreateMutable();

    CGContextSetLineWidth(signalContext, 0.4); //LineWidth
    CGContextBeginPath(signalContext);
    CGContextSetStrokeColorWithColor(signalContext, [UIColor purpleColor].CGColor);
    CGPathMoveToPoint(signalLine, 0, 0, i*_rowHeigth + _sbd/2);//Startpoint
    CGPathAddLineToPoint(signalLine, 0, self.frame.size.width, i*_rowHeigth + _sbd/2);
    CGContextAddPath(signalContext, signalLine);

    //CGContextClosePath(signalLine); didnt work
    CGContextStrokePath(signalContext);
    //CGContextRelease(signalContext); didnt work
}

}

Was it helpful?

Solution

According to CoreFoundation Ownership Policy, you are the owner of signalLine, which came from a Create function. You must call CFRelease(signalLine) to release it.

The safest way to do this is to ensure it is not NULL first:

if (signalLine) CFRelease(signalLine);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top