Note that there are some explanatory texts on larger screens.

plurals
  1. POtabBarController memory leak
    primarykey
    data
    text
    <p>In my AppDelegate I initiate a tabBar Controller, to which a bunch of navigationController is added as tabs. I use the following code:</p> <pre><code>// Init tabBar Controller tabBarController = [[[UITabBarController alloc] init] retain]; // Init Root Views of navigation controllers FirstRootViewController* firstViewController = [[[FirstRootViewController alloc] init] autorelease]; SecondRootViewController* secondViewController = [[[SecondRootViewController alloc] init] autorelease]; ThirdRootViewController* thirdViewController = [[[ThirdRootViewController alloc] init] autorelease]; // Init Navigation controllers of tabs UINavigationController* firstNavController = [[[UINavigationController alloc] initWithRootViewController:firstViewController] autorelease]; UINavigationController* secondNavController = [[[UINavigationController alloc] initWithRootViewController:secondViewController] autorelease]; UINavigationController* thirdNavController = [[[UINavigationController alloc] initWithRootViewController:thirdViewController] autorelease]; firstNavController.navigationBar.barStyle = UIBarStyleBlack; secondNavController.navigationBar.barStyle = UIBarStyleBlack; thirdNavController.navigationBar.barStyle = UIBarStyleBlack; // Create array for tabBarController and add navigation controllers to tabBarController NSArray *navigationControllers = [NSArray arrayWithObjects:firstNavController, secondNavController, thirdNavController, nil]; tabBarController.viewControllers = navigationControllers; [window addSubview:tabBarController.view]; </code></pre> <p>And the dealloc function:</p> <pre><code>- (void)dealloc { [window release]; [tabBarController release]; [super dealloc]; } </code></pre> <p>firstNavController are the navigation controllers to be added which are properly released alltogether a few lines later (they are created using alloc). tabBarController is a class variable which has been created using @property (nonatomic, retain) and @synthesize tabBarController. It receives a release command in the dealloc method. Now instruments tells me that I have two memory leaks on the line with "tabBarController.viewControllers = navigatioControllers". I have tortured my head, yet I don't see why: From my understanding, navigationControllers should get released automatically and if I send it a release command a few lines later, the app crashes, so I guess I am right. Any guesses whats wrong?</p> <p>Thanks a lot!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload