我找到了这个 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;
}
最佳答案
您可能需要使用 Profile - Leaks 工具来检测泄漏。 Zombies instrument 通过为任何已释放的对象放置 NSZombie 对象来工作,这就是为什么您会看到已分配对象的数量持续增加的原因。
关于ios - 我的油漆泄漏内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8760747/