EXC_BAD_ACCESS signal received

前端 未结 30 3193
轮回少年
轮回少年 2020-11-22 06:37

When deploying the application to the device, the program will quit after a few cycles with the following error:

Program received signal: \"EXC_BAD_ACCESS\".         


        
30条回答
  •  庸人自扰
    2020-11-22 06:51

    A major cause of EXC_BAD_ACCESS is from trying to access released objects.

    To find out how to troubleshoot this, read this document: DebuggingAutoReleasePool

    Even if you don't think you are "releasing auto-released objects", this will apply to you.

    This method works extremely well. I use it all the time with great success!!

    In summary, this explains how to use Cocoa's NSZombie debugging class and the command line "malloc_history" tool to find exactly what released object has been accessed in your code.

    Sidenote:

    Running Instruments and checking for leaks will not help troubleshoot EXC_BAD_ACCESS. I'm pretty sure memory leaks have nothing to do with EXC_BAD_ACCESS. The definition of a leak is an object that you no longer have access to, and you therefore cannot call it.

    UPDATE: I now use Instruments to debug Leaks. From Xcode 4.2, choose Product->Profile and when Instruments launches, choose "Zombies".

提交回复
热议问题