Because if main() creates an NSAutoreleasePool, and drains it before the program exits, then even though it can prevent memory leaks, the whole process’s memory space is going to be freed up next anyway — does it matter if we free up little pieces if the whole piece is freed up next? In fact, if it keeps on working on the small pieces, won’t it cause the program to exit slower?
(drain can invoke release, which in turn invoke dealloc, but if dealloc is only to free up memory but nothing else (such as closing a file), then the drain won’t help freeing up memory)
It’s considered good practice to clean up after yourself where possible, rather than relying on the environment to do it for you. If all you’re worried about is memory usage, then no, the topmost pool isn’t strictly necessary–but that’s not the only thing you need to consider. Objects may do things other than free memory in their
-deallocmethods (e.g. flushing files to disk, releasing rare OS resources, or freeing up resources that aren’t otherwise returned to the system on process exit.)Not to mention the console spam when objects get autoreleased without a pool present.