There are plenty of objects in each iPhone app witch will live forever till app dies. They are: application delegate, window, main view controller, may be navigation or tab controller, all the objects within them. Why on Earth should I release them just before quit spending precious CPU cycles? As far as I understand, apps process will be terminated, so it's heap, consistent or not will be gone too.
So why should I release them? Apple's dev manuals insist on it like in code sample following (from iPhone Development Guide). It's just first place I've found searching by word dealloc in library.
@implementation HelloWorldAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
MyView *view = [[MyView alloc] initWithFrame:[window frame]];
[window addSubview:view];
[view release];
[window makeKeyAndVisible];
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
From Discussions section on NHObject-dealloc method:
Note that when an application terminates, objects may not be sent a dealloc message since the process’s memory is automatically cleared on exit—it is more efficient simply to allow the operating system to clean up resources than to invoke all the memory management methods. For this and other reasons, you should not manage scarce resources in dealloc
But dealloc method in sample above is called in current implementation if your application is fast enough to react to applicationWillTerminate within 15 seconds.
So again. Should I avoid writing dealloc method above for app exit speed or are there any problems with such approach?