If you are like me (a C/C++ programmer who has to write small amounts of Objective C for a certain mobile platform), this document contains pretty much all of the answers you need regarding the question "am I leaking memory?"
I'll try to limit the ranting - but there are definitely some surprising things here, particularly if you are used to a more traditional reference-counted environment. Key points:
- Reference counting is not automatic like Java, so you absolutely can screw it up.
- You are expected to not create cyclic reference-count dependencies - see "weak vs. strong" references.
- Apple's naming conventions are very consistent, once you understand them. This is important because the rules for memory allocation vary in a way that make the APIs more convenient, but less consistent. (That is, sometimes objects are retained or auto-retained for you. Lacking automatic reference counting of everything in the language, this is necessary to keep code from coming completely bloated. But it means that you, the programmer, have to be able to look at an Obj-C method and go "I [don't] need to retain" and get the answer right 100% of the time.
- autorelease basically acts as a deferred release, similar to a deferred-destroyer idiom in C++.