How to debug “message sent to deallocated instance” in Xcode4?

后端 未结 2 1285
旧巷少年郎
旧巷少年郎 2020-12-12 10:56

I pressed ALT+CMD+R and activated NSZombieEnabled in Arguments > Environment Variables. Additionally, I activated it in Diagnostics > Memory Management > Enable Zombie Objec

2条回答
  •  無奈伤痛
    2020-12-12 11:40

    In addition to Jeff's great answer; to do almost the same thing, but without having to open Instruments or profile your App, you can set NSZombieEnabled, MallocStackLogging, and guard malloc in the debugger. Then, when your App crashes, type this in the gdb console:

    (gdb) info malloc-history 0x543216
    

    Replace 0x543216 with the address of the object that caused the crash, and you will get a much more useful stack trace and it should help you pinpoint the exact line in your code that is causing the problem.

    This article has some additional infoz.

提交回复
热议问题