On Dealloc, Remember to Stop Observing

I just spent ~1 hour tracking down a crash. The problem was that my object wasn’t unregistering its notification observer on dealloc. Why did this take so long to figure out? Well, it didn’t help that the backtrace in the core was useless[1]. The only hint I had that it was a dead object causing the pain was gdb was nice enough to tell me:

Program received signal:  "EXCBADACCESS”.
So remember, unregister your observers when you die.

[1] - in hindsight, there were plenty of crumbs lying around: notification posting was all over the stack, EXCBADACCESS, and the fact that it happened after closing a document should have been enough, but not this morning.

Leave a Reply


© 2006 roobasoft, LLC