快速的問題,儀器公司報告在這裏泄漏...爲什麼Instruments在此代碼中報告內存泄漏?
MyViewController *myVC = [[MyViewController alloc] initWithNibName:@"myView" bundle:nil];
[self.navigationController pushViewController:myVC animated:YES]; //<<<<---- !00% leak according to Instruments
[myVC release];
我明白myVC由導航控制器保留的,所以我認爲導航控制器釋放他們時,認爲被彈出堆棧資產淨值?
此外,還有另一個棘手的一個在我的環之一,靜態分析儀在這裏報告一個潛在的泄漏...
//Walk through the scheduled alarms and create notifications
NSMutableArray *fireDates = [[NSMutableArray alloc] init];
for(NSDate *fireDate in fireDates) //<<<<---- Static analyzer is reporting potential leak here
{
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
{
[fireDates release];
return;
}
localNotif.fireDate = fireDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = [NSString stringWithFormat:@"%@", alarm.Label];
localNotif.alertAction = NSLocalizedString(@"Launch", nil);
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.userInfo = infoDict;
localNotif.repeatInterval = NSWeekCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
}
[fireDates release];
我需要以某種方式釋放fireDate?
在此先感謝您的幫助!
靜態分析儀一般都很好......也許不要忽略缺少的代碼... – Eiko 2010-08-19 21:16:02
謝謝,Eiko,我剛剛更新了我的問題以包含缺少的代碼。你的想法? – BeachRunnerFred 2010-08-19 21:23:24
你正在模擬器或設備上運行測試嗎?我注意到對模擬器,泄漏程序顯示錯誤的泄漏。 – 2010-08-19 21:35:39