PDA

View Full Version : Why does this method leak?




ArtOfWarfare
Nov 18, 2009, 02:21 PM
When I attempt to build and run with absolutely nothing, Instruments reports no leaks.

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
}

When I attempt to build and run just this, Instruments reports a single leak.

- (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.

- (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".



ritsard
Nov 19, 2009, 02:20 PM
do you have anything connected via IB? Is the navigation controller set as an outlet there?

ArtOfWarfare
Nov 19, 2009, 03:05 PM
do you have anything connected via IB? Is the navigation controller set as an outlet there?

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?

PhoneyDeveloper
Nov 19, 2009, 04:44 PM
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?

ArtOfWarfare
Nov 19, 2009, 08:37 PM
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?

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.