快速的问题,仪器公司报告在这里泄漏...为什么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