title: Large retain count with a recent created object. Objective-C
body: <p>I'm getting an strange case of excessive retain counts for a view controller that I'm loading when a button is pushed.</p>
  
  <p>This is the code:</p>
  
  <pre><code>-(IBAction)new
  {
      if (!viewSpace)
          viewSpace = [[ViewSpace alloc] initWithNibName:@"ViewSpace" bundle:nil];
  
      viewSpace.delegate = self;
  
      viewSpace.view.frame = CGRectMake(0, 0, viewSpace.view.frame.size.width, viewSpace.view.frame.size.height);
  
      [self presentModalViewController:viewSpace animated:YES];
  
      NSLog(@"Count Retain: %d",[viewSpace retainCount]);
  
  }
  -(void)viewSpaceWasDissmissed:(id)sender
  {
      [self dismissModalViewControllerAnimated:YES];
      [viewSpace release];    
      NSLog(@"Count Retain: %d",[viewSpace retainCount]);
  }
  </code></pre>
  
  <p>When the IBAction New is executed first time, the retain count is 5 when just is created. (It must be 1).</p>
  
  <p>When the ViewSpace object must be unload calls viewSpaceWasDismissed function in order to remove the modal view and release the previous object.</p>
  
  <p>The problem is that never the retain count reach 0 and the dealloc method of ViewSpace never is called causing memory leaks.</p>
  
  <p>My question is how is possible that a recently created ViewController have 5 retains? I made sure that is never created before.</p>
  
  <p>Thanks.</p>