I was having some issues with Memory Management and dealloc'ing objects (and subsequently crashing software) and found the following resources very useful:
To paraphrase
- Never
dealloc
, use release
- If you create an object it's your responsibility to release it
- If you want to own an object or use and object returned from another object you should
retain
it - Don't release an object you didn't create or own
Now I remember why I like programming languages that take memory management out of my hands. Last time I touched memory management was at university, and it was a pain then too.
Good thing is that Objective-C/Cocoa has those simple rules/conventions to follow. Memory Management is not onerous on the mac/iPhone, so I can't complain too much.