我用儀器跟蹤了內存泄漏。我總是以負責任的圖書館爲基礎的信息結束。當我跟蹤下來在我的代碼,我會在這裏結束,但有沒有錯與我的內存管理:是否存在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