Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6615473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:27:56+00:00 2026-05-25T20:27:56+00:00

I’m having some trouble with memory leaks on one of my view controllers. From

  • 0

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:

-(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]; // <--Instruments says leak is here
    [svc release];

    if (AdsAreEnabled) {
        ADBannerView *adBanner = SharedAdBannerView;
        adBanner.delegate = nil;
    }    
}

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.

A couple other leaks are only leaking in main, either NSCFstrings, SKProduct and SKProductInternal, all of which I think are only brought up in the GCD queue. Here’s where instruments is telling me the problem is:

int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil); // <-- Instruments says leak is here
    [pool release];
    return retVal;
}

Here’s my code where I call GCD, in its own method that gets called during viewDidLoad of the SettingsViewController:

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); 
}

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 dealloc so it’s not that. I made sure to remove the transaction observer in my IAP manager’s dealloc, so it’s not that.

Any suggestions? Anything else you’d need to know to help me figure out where I’ve gone so terribly terribly wrong here?

Edited to add: I release sectionNames in SVC’s dealloc method, so that’s not it either.

Edit 2: I tried auto-releasing svc when I alloc it (and getting rid of the corresponding release) but I’m still getting the same leaks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:27:57+00:00Added an answer on May 25, 2026 at 8:27 pm

    Well, I finally figured it out with some troubleshooting help from a friend – for some reason I forgot you still have to release an IBOutlet ivar even if you haven’t set it up as a property (for some reason I thought an IBOutlet autoreleased if it wasn’t a property, which is not true), and once I had the proper releases in dealloc, all my leaks magically went away.

    Duh. Another thing to add to my Idiot Checklist, I suppose. 🙂

    Thanks for the suggestions, guys!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a view passing on information from a database: def serve_article(request, id): served_article
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.