我的油漆泄漏记忆?

时间:2012-01-06 16:08:17

标签: ios cocoa-touch memory-management

我找到了这个paint app,并使用了Profile / Zombie乐器。显然,当你画画时,记忆会不断上升。

我想我找到了泄漏的地方,但我无法弄清楚它究竟是什么问题。

有人有想法吗?这是问题代码:

 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    mouseSwiped = YES;

    UITouch *touch = [touches anyObject];   
    CGPoint currentPoint = [touch locationInView:self.view];
    currentPoint.y -= 0;


    UIGraphicsBeginImageContext(self.view.frame.size);
    [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10.0);
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
    CGContextBeginPath(UIGraphicsGetCurrentContext());
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
    CGContextStrokePath(UIGraphicsGetCurrentContext());
    drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    lastPoint = currentPoint;

}

1 个答案:

答案 0 :(得分:2)

您可能需要使用Profile-Leaks仪器来检测泄漏。 Zombies工具通过为任何解除分配的对象放置NSZombie对象来工作,这就是为什么你看到分配对象数量不断增加的原因。

相关问题