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

后端 未结 2 1284
旧巷少年郎
旧巷少年郎 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:39

    If this crops up again, you can run a dedicated Zombies instrument. Hit Command+I to profile the app and select the Zombies instrument (you must be running on the simulator). If you get a zombie, you can display the entire memory history (each retain/release) for that object, which is immensely helpful in tracking down errors.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题