0

アプリで発生しているメモリ リークを見つけようとしています。アプリケーションが読み込まれると、instuments のようなメモリ リークがすぐに発生します。

リーク

循環と根

どうすればそれをデバッグできますか? アプリをどれだけ長く実行しても、何をしても、アプリケーションがロードされたときにのみ再現されません。

これがデリゲートの私のコードです

- (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 に答える