views:

82

answers:

2

Hello,

I started to learn using Instrument, but I cannot figure it out. After I start my application, the UI shows up, I do nothing and after few seconds I can see memory leak detected: alt text

When I have a look at the second leak I can see the following stack: alt text

When I double click on the cell related to my code I can see that it is pointing to the following line of code:

[window addSubview:newPostUIViewController.view];

from the method:

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
//creating view controller
newPostUIViewController = [[NewPostUIViewController alloc] initWithNibName:@"NewPostView" bundle:nil]; 
newPostUIViewController.title = @"Post it!";
[window addSubview:newPostUIViewController.view];

// Override point for customization after application launch
[window makeKeyAndVisible];
}

I wonder, how this can be a reason of a leak? I release newPostUIViewController in the dealloc method of PostItAppDelegate class.

Any ideas how this could be explained?

A: 

You did not provide an autorelease or release to balance your init. Just in case you haven't read through it already, have a look at the memory management guide is a great help.

slf
Thanks for your suggestion, however, I release both newPostUIViewController and window in the dealloc method of PostItAppDelegate. Should I call the release in some other place?
Jakub
@Jakub can you post some more code showing how you use the controller? It's possible that the controller has an extra retain, but not on that line.
slf
A: 

Looking at link text allows to say that this is Simulator problem, not the code problem.

Jakub