Sunday, April 3, 2011

Debugging EXC_BAD_ACCESS

I'm generally pretty good about tracking down EXC_BAD_ACCESS errors but I had one tonight that really got me going. Seems that sometimes I was switching UIWebView windows too fast and the delegate was being called after the UIWebView was already dealloc'd. Once I cleared the delegate before releasing, all was well.

I probably would still be looking for this problem were it not for this site which suggested the following:

Go to "Targets" tab, open "Executables" and add the following environment variables with values set to "YES" (sans quotes)

NSDebugEnabled
NSZombieEnabled
MallocStackLogging


As soon as it detects any activity with with the zombie it'll throw an exception. For more info, you can also run the gdb command: shell malloc_history <pid> <address> - in my case it was a buttload o' crap, but at least it indicated that the problem was related to a delegate.

Definitely one for the saveme.txt file.

No comments:

Post a Comment