0

我正在尝试查找我的应用程序中的内存泄漏。当应用程序加载时,我立即得到一个看起来像在仪器中的内存泄漏

泄漏

循环和根

我该如何调试?无论我运行我的应用程序多久或我做什么,它都不会自我复制,只有在应用程序加载时。

这是我在委托中的代码

- (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];
}
4

2 回答 2

2

请使用泄漏的调用树视图,这将显示问题发生的位置并帮助您进行故障排除。还可以尝试使用真实设备,因为模拟器可能会显示误报。

泄漏调用树

于 2012-08-24T08:05:33.840 回答
1

释放未释放的homeNavigationController并检查您是否在其他地方丢失。

于 2012-08-24T08:03:13.943 回答