I am currenty seeing a problem with memory leaks, it seems to come from this code:
- (void)drawRect:(CGRect)rect
{
CGImageRef cgImage = CGBitmapContextCreateImage(offScreenBuffer);
UIImage *uiImage = [[UIImage alloc] initWithCGImage:cgImage];
CGImageRelease(cgImage);
[uiImage drawInRect:self.bounds];
[uiImage release];
}
this method is called from touches events ...
-(void)drawPoint:(UITouch *)touch {
currentLoc = [[PointLocation alloc] init];
currentLoc.location = [touch locationInView:self];
self.previousPoint = self.point;
self.point = currentLoc;
[self drawToBuffer];
[currentLoc release];
}
and this is draw to buffer....
-(void)drawToBuffer {
CGFloat color[4] = {R,G,B,A};
if (self.previousPoint != nil) {
CGContextSetRGBStrokeColor(offScreenBuffer, color[0],color[1],color[2],color[3]);
CGContextBeginPath(offScreenBuffer);
CGContextSetLineWidth(offScreenBuffer, lane);
CGContextSetLineCap(offScreenBuffer, kCGLineCapRound);
CGContextMoveToPoint(offScreenBuffer, previousPoint.location.x, previousPoint.location.y);
CGContextAddLineToPoint(offScreenBuffer, point.location.x, point.location.y);
CGContextDrawPath(offScreenBuffer, kCGPathStroke);
}
[self setNeedsDisplay];
}
this is really slow....:( And I don't know why...
Every single time I draw in the selected view, this is called, but every time I need to create an image and show it on the screen. Is there any possibility how to do this another way??