Q:

Why dealloc is not called?

I am writing some test code on Cocoa.  Have put the AppController object in IB.  An NSMutableArray is declared and initialized in the AppController.  Everything runs ok, as users can input to the array and its content is displayed on a NSTableView etc.
Then I add a - (void) dealloc {} method to the AppController.  My question is : why is it not being called at all when the program is terminated by pressing the "red tasks" button?  Just that I wish to explicitly free the memory associated with the array before the program ends.  And do I need to explicitly free the array ?   (no Garbage Collection) 

A:

Memory is not freed when a program terminates, since all memory associated with the process is automatically bulk-freed when it dies anyway. If you need to do non-memory related cleanup at termination time, use NSApp's delegate method -applicationWillTerminate:

