views:

45

answers:

2

In controller named controller1, I am pushing a modal view controller

     AddConversationViewController *addController = [[AddConversationViewController alloc] 
 initWithNibName:@"AddConversationViewController" bundle:nil];
 //addController.delegate = self;    
 UINavigationController *navigationController = [[UINavigationController alloc]
 initWithRootViewController:addController];
 [self presentModalViewController:navigationController animated:YES];
 [addController release];
 [navigationController release];

and then in that addcontroller, I have allocated several object. but in the dealloc method, when i release those objects, I will get BAD_ACCESS warning when i dismiss the modal view controller. If I don't release those objects I have allocated, it doesn't give the BAD_ACCESS warning. those objects I have allocated before are not released nor retained.

Does anybody know how to fix this memory leak?

A: 

I can only guess that when you dismiss the addController, you didn't deallocate the addController yet but you deallocate its objects.

So, can you try to put deallocate code into dealloc method of the addController

vodkhang
that's what i did.and then when i called the dealloc method in addcontroller and tried to removed those objects i created in addcontroller class, i get BAD_ACCESS. that's weird
David Gao
DO you call the [addController dealloc] directly? At which line of code in which method, the BAD_ACCESS happened?
vodkhang
the bad access happened when it's calling the dealloc method inside the addcontroller.
David Gao
Uhm, can you post those codes? The dealloc method of addcontroller?
vodkhang
A: 

Using Xcode 3.2 you can use the Clang Static Analyzer to see exactly where your memory management is going wrong. Simply choose "Build and Analyze" from the Build menu to use the tool.

jsumners