1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Why does this method leak?

Discussion in 'iPhone/iPad Programming' started by ArtOfWarfare, Nov 18, 2009.

  1. macrumors 603

    ArtOfWarfare

    #1
    When I attempt to build and run with absolutely nothing, Instruments reports no leaks.

    Code:
    - (void)applicationDidFinishLaunching:(UIApplication *)application
    {
    }
    When I attempt to build and run just this, Instruments reports a single leak.

    Code:
    - (void)applicationDidFinishLaunching:(UIApplication *)application
    {
       navigationController = [[UINavigationController alloc] init];
       [window addSubview:navigationController.view];
    }
    When I attempt to build and run this, I still get a single leak.

    Code:
    - (void)applicationDidFinishLaunching:(UIApplication *)application
    {
       navigationController = [[UINavigationController alloc] init];
       [window addSubview:navigationController.view];
       [navigationController release];
       [window release];
    }
    What is leaking in the second and third bit of code? The third example releases everything, so I don't understand how it's possible for it to leak anything.

    It says the responsible library is CoreGraphics and the responsible frame is "open_handle_to_dylib_path".
     
  2. macrumors member

    ritsard

    #2
    do you have anything connected via IB? Is the navigation controller set as an outlet there?
     
  3. macrumors 603

    ArtOfWarfare

    #3
    No.

    I do have a full program that actually does stuff, but it had two leaks. I found and fixed one of them. The other one I couldn't find so I finally decided to try commenting out portions of code. Eventually I got down to just those two lines. Running just that will cause instruments to report a leak. Commenting those out has no leaks reported. Trying to release everything still leaves a leak. So...

    IDK, have I found a leak in Apple's code?
     
  4. macrumors 68030

    PhoneyDeveloper

    #4
    What is it that leaks tells you is leaking?

    When does leaks tell you that a leak happened? When this method is run or some time later?
     
  5. macrumors 603

    ArtOfWarfare

    #5
    After the screen changes from black.

    And I realized that I was mistaken in answering the first question, there is a NIB that was automatically created with the project. I never changed anything about it... my interface is handled all programmatically.
     

Share This Page