【发布时间】:2011-01-29 15:46:43
【问题描述】:
我用仪器找到了内存泄漏。我总是得到负责任的图书馆是基金会的信息。当我在我的代码中追踪它时,我最终到了这里,但我的内存管理没有任何问题:
- (void)setupTimer {
// stop timer if still there
[self stopAnimationTimer];
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(step:) userInfo:nil repeats:YES];
self.animationTimer = timer; // retain property, -release in -dealloc method
}
animationTimer 属性保留了计时器。在 -dealloc 我 -release 它。
现在看起来像一个框架错误?我检查了 iPhone OS 3.0 和 3.1,每次我像这样使用 NSTimer 时都会出现这个问题。知道还有什么问题吗?
(我的内存泄漏扫描间隔是 0.1 秒。但同样是 5 秒)
【问题讨论】:
-
stopAnimationTimer是做什么的?我认为您需要使计时器无效(我希望您在stopAnimationTimer方法中这样做)。 -
是的,它只是使计时器无效并将属性设置为 nil。
标签: iphone memory-management memory-leaks instruments