EXC_BAD_ACCESS

Tuesday, July 7, 2009

iNytt had a bug that caused the application to crash after a while, I spent some time trying to find fault when it came reasonably random.

The error message was as follows: EXC_BAD_ACCESS.

This error message occurs when you release the object more times than you have the retainer. So if you releases the object that is not in memory. It is often difficult to find the error when the error message does not tell where in the code you have done it. You must go through your code to check, a good opportunity to make a small dish with other words.;)

In my case I release an object in a dealloc method, I'd release the object once before.

A quick tip to avoid this error message is to remember this rule:

  • If you use Alloc, copy or retain an object, always release the object with the release or automatic release. So long as you receive an item, you have no responsibility to release it yourself.

For more information read this article about memory handling in objective-c.

The update to iNytt is sent to Apple, where it awaits approval.

Categories → iPhone

    Write a comment