[英]iOS memory leak on app loading
I'm trying to find a memory leak i have on my app. 我正在尝试查找我的应用程序中存在的内存泄漏。 When the application loads i instantly get a memory leak that looks like that in instuments
当应用程序加载时,我立即收到一个内存泄漏,看起来像是仪器
how can i debug that ? 我该如何调试呢? it doesn't reproduce it self no matter how long i run my app or what i do, only when the applications loads.
无论我运行我的应用程序多长时间或执行什么操作,它都不会自我重现,仅当应用程序加载时。
and here is my code in the delegate 这是我在委托中的代码
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
tabBarController = [[UITabBarController alloc] init];
search = [[iPhoneView alloc] initWithNibName:@"iPhoneView" bundle:nil];
homeNavigationController = [[UINavigationController alloc] initWithRootViewController:search];
favouritesNavigationController = [[UINavigationController alloc] init];
favoritesViewController = [[FavoritesViewController alloc]init];
[favouritesNavigationController pushViewController:favoritesViewController animated:NO];
aboutUsViewController =[[AboutUsViewController alloc] init];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"toolbox" image:[UIImage imageNamed:@"aboutus"] tag:0];
aboutUsViewController.tabBarItem = item;
[item release];
UITabBarItem *item2 = [[UITabBarItem alloc] initWithTitle:@"αγαπημένα" image:[UIImage imageNamed:@"favorites"] tag:0];
favouritesNavigationController.tabBarItem = item2;
[item2 release];
NSArray *tabBarControllerCollection = [NSArray arrayWithObjects:homeNavigationController,favouritesNavigationController,aboutUsViewController,nil];
[tabBarController setViewControllers:tabBarControllerCollection animated:NO];
[window setRootViewController:tabBarController];
[tabBarControllerCollection release]; //added that for the leaks
//[window addSubview:tabBarController.view]; for the warning thing about window and root view controller
[window makeKeyAndVisible];
}
- (void)dealloc {
[tabBarController release];
[search release];
[favoritesViewController release];
[favouritesNavigationController release];
[aboutUsViewController release];
[window release];
[super dealloc];
}
Please use the Call Tree view of your Leaks, that will show where the problem happened and will help you troubleshoot. 请使用泄漏的“调用树”视图,该视图将显示问题发生的位置并帮助您进行故障排除。 Also try with a real device as the simulator might show false-positives.
还要尝试使用真实的设备,因为模拟器可能会显示假阳性。
释放未释放的homeNavigationController ,并检查是否缺少其他地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.