Xcode调试方法

来源:互联网 发布:2016年网络搜索话题 编辑:程序博客网 时间:2024/06/05 20:48

设置NSZombieEnabled、MallocStackLogging、NSAutoreleaseFreedObjectCheckEnabled、NSDebugEnabled

第一种设置方法:

1. Product->Edit Scheme...->Run...->EnvironmentVariables.2. add NSZombieEnabled,set the value with YES3. add MallocStackLogging, set the value with YES.4. add NSAutoreleaseFreedObjectCheckEnabled, set the value with YES.5. add NSDebugEnabled, set the value with YES.

设置NSZombieEnabled、MallocStackLogging、NSAutoreleaseFreedObjectCheckEnabled、NSDebugEnabled环境变量

使用场景: 
主要为了解决EXC_BAD_ACCESS问题,MallocStackLogging用来启用malloc记录(使用方式 malloc_history ${App_PID} ${Object_instance_addr})。

第二种设置方法:

直接通过Editing Scheme窗口中的Run选项下的Diagnostics选项卡来设置。

Enable zombie objects

需要注意的问题: 
NSZombieEnabled只能在调试的时候使用,千万不要忘记在产品发布的时候去掉,因为NSZombieEnabled不会真正去释放dealloc对象的内存。

0 0