iOS 内存错误调试(EXC_BAD_ACCESS)
内存错误crash现场:
Thread堆栈:
有可能是访问被释放对象造成,根据现场并不能找到具体哪个对象出现内存错误。
1.开启僵尸对象调试
Edit Scheme->Debug->Diagnostics->Enable Zombie Objects
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调试器可以使用如下命令查看
(gdb) info malloc-history 0x185942a0
(1)Profile your project
(2)Select Zombies from the list of instruments
(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)定位问题
不断尝试、不断调整、不断学习、不断进步