In iOS programming, the EXC_BAD_ACCESS happens when application try to access some deallocated objects, but the Debugger Console usually display a simple message of "EXC_BAD_ACCESS", here is an useful solution to track the deallocated object.
- Set NSZombieEnabled = YES. With this argument, console will display a little bit more information, like "method : message sent to deallocated instance ...", sometime we can track the object in the method when it is easy to find.
- Set MallocStackLoggingNoCompact = 1, this argument allow to display alloc history of the object, for example: we got a message "message sent to deallocated instance 0x58448e0", type "info malloc-history 0x58448e0" in the console will display the allocate history of object 0x58448e0, which contains object allocation and deallocation, it is really useful to debug the incorrect release call.
To setup these 2 arguments, you should go to "Project"->"Edit Active Executable project name", add these 2 variables in "Variables to be set in the enviroment", names are "NSZombieEnabled" and "MallocStackLoggingNoCompact", values are "YES" and "1". And check the checkbox to active.
Don't forget remove these variables when you release your application.
1 comment:
Thx a lot !
Post a Comment