title: Memory leaks in pushViewController and (I think) coming back from a GCD queue
body: <p>I'm having some trouble with memory leaks on one of my view controllers. From my main view controller, I'm pushing my settings view controller like so: </p>
  
  <pre><code>-(IBAction)launchSettings {
      SettingsViewController *svc = [[SettingsViewController alloc] init];
      svc.title = @"title of app";
  
      //this actually adds a back button for the next vc pushed
      self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil] autorelease];
  
      [[self navigationController] pushViewController:svc animated:YES]; // &lt;--Instruments says leak is here
      [svc release];
  
      if (AdsAreEnabled) {
          ADBannerView *adBanner = SharedAdBannerView;
          adBanner.delegate = nil;
      }    
  }
  </code></pre>
  
  <p>So, when I initially push the view controller, I have no leaks. The view controller uses a GCD queue to load up my In-App Purchase store, and when I hit the "back" button I've created above to pop it off the stack, that's when a crapload of leaks show up in Instruments. A bunch are showing up in the line of code where I push the view controller, which makes no sense to me since I immediately release it. </p>
  
  <p>A couple other leaks are only leaking in main, either <code>NSCFstring</code>s, <code>SKProduct</code> and <code>SKProductInternal</code>, all of which I think are only brought up in the GCD queue. Here's where instruments is telling me the problem is: </p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
      int retVal = UIApplicationMain(argc, argv, nil, nil); // &lt;-- Instruments says leak is here
      [pool release];
      return retVal;
  }
  </code></pre>
  
  <p>Here's my code where I call GCD, in its own method that gets called during <code>viewDidLoad</code> of the <code>SettingsViewController</code>:</p>
  
  <pre><code>if ([iapManager canMakePurchases]) {
      // Display a store to the user.
      iapTableView.sectionFooterHeight = 0;
      iapTableView.rowHeight = 50;
      iapTableView.scrollEnabled = NO;
      //init sectionNames here to avoid leakage.
      sectionNames = [[NSArray alloc] initWithObjects:@"Get Rid of Ads!", nil];
      [spinner startAnimating];
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadStore) name:kInAppPurchaseManagerProductsFetchedNotification object:iapManager];
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadStore) name:kTransactionCompleted object:iapManager];
      //Run this in seperate thread to avoid UI lockup
      dispatch_queue_t store_check = dispatch_queue_create("see if store is available", NULL);
      dispatch_async(store_check, ^ {
          [iapManager loadStore];
      });
      dispatch_release(store_check); 
  }
  </code></pre>
  
  <p>I'm a little stumped as to what I've done wrong here - I use exactly the same technique to load up a different view controller and it doesn't leak, and I can't figure out how to tell if/where my GCD stuff is leaking - everything's been analyzed repeatedly and comes out clean. I remove my observer from the Notification Center in SVC's <code>dealloc</code> so it's not that. I made sure to remove the transaction observer in my IAP manager's <code>dealloc</code>, so it's not that.</p>
  
  <p>Any suggestions? Anything else you'd need to know to help me figure out where I've gone so terribly terribly wrong here? </p>
  
  <p><em>Edited to add: I release sectionNames in SVC's <code>dealloc</code> method, so that's not it either.</em></p>
  
  <p><em>Edit 2: I tried auto-<code>releasing</code> svc when I <code>alloc</code> it (and getting rid of the corresponding <code>release</code>) but I'm still getting the same leaks.</em></p>