iOS 內存錯誤調試(EXC_BAD_ACCESS)

內存錯誤crash現場:ios

Thread堆棧:xcode

有多是訪問被釋放對象形成,根據現場並不能找到具體哪一個對象出現內存錯誤。app

1.開啓殭屍對象調試this

Edit Scheme->Debug->Diagnostics->Enable Zombie Objectsspa

2.閃退後查看控制檯,看輸出應該是某個Button出錯調試

2016-10-14 16:40:49.959 funmiosbr_ZQB[2761:388881] *** -[UIButton setHidden:]: message sent to deallocated instance 0x185942a0

3.因爲新版xcode默認調試器爲lldb,舊版本gdb調試器可使用以下命令查看code

(gdb) info malloc-history 0x185942a0

(1)Profile your project對象

(2)Select Zombies from the list of instrumentsblog

(3)Make your app trigger the problem內存

(4)At this point you should be presented with the address that was already deallocated and you can explore it.

(5)定位問題

相關文章
相關標籤/搜索