I always push a new view controller onto the stack like this:
MyViewController *vc = [[MyViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
And all works well when it comes to popping it off the stack with:
[self.navigationController popViewControllerAnimated:NO];
But now when I pop the vc off the stack I get a crash in main.m stating a bad access at line:int retVal = UIApplicationMain(argc, argv, nil, nil);
But now if I comment out [vc release] no more crash?
But why and surely this leaks memory as Im not releasing something I created?
Your memory management looks fine. Perhaps you are mismanaging the memory of something inside of your vc. What does the dealloc method of MyViewController look like?
My guess is you are using the incorrect init method (perhaps initWithNibName:bundle:) and you are releasing ivars in dealloc that were never properly initialized.