title: tabBarController memory leak
body: <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 altogether a few lines later (they are created using alloc).</p>
  
  <p>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.</p>
  
  <p>Now instruments tells me that I have two memory leaks on the line with "tabBarController.viewControllers = navigationController".</p>
  
  <p>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.</p>
  
  <p>Any guesses whats wrong?</p>
  
  <p>Thanks a lot!</p>