我用仪器跟踪了内存泄漏。我总是以负责任的图书馆为基础的信息结束。当我跟踪下来在我的代码,我会在这里结束,但有没有错与我的内存管理:是否存在NSCFTimer内存泄漏?
- (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我发布它。
现在看起来像一个框架错误?我使用iPhone OS 3.0和3.1进行了检查,每当我使用NSTimer时都会遇到这个问题。任何想法还有什么可能是问题?
(我的内存泄漏扫描时间间隔为0.1秒。但是,拥有5秒同样的事情)
'stopAnimationTimer'做什么?我认为你需要使计时器无效(并且我希望你在'stopAnimationTimer'方法中做到这一点)。 – bddckr 2010-03-19 21:40:35
是的,它只是使计时器无效并将属性设置为零。 – dontWatchMyProfile 2010-03-19 22:17:15