关于xcode Objective-C EXC_BAD_ACCESS问题

本文提供了解决iPhone开发中遇到的EXC_BAD_ACCESS错误的方法,包括在Xcode中设置gdb命令、使用Instruments工具进行调试等步骤。重点介绍了如何通过这些工具快速定位并解决内存管理相关的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

XCode调试技巧之EXC_BAD_ACCESS中BUG解决是本文要介绍的内容,在iphone开发的时候EXC_BAD_ACCESS这个bug时不容易找到原因的,
自己在网上找到的有关于这个问题的方法,研究了一下还真把问题给解决了!
http://www.iteye.com/topic/550550
http://lovebirdegg.iteye.com/blog/550489
http://xcodev.com/wordpress/?p=209
http://mobile.51cto.com/iphone-279455.htm
http://blog.youkuaiyun.com/sjzsp/article/details/6386987
http://stackoverflow.com/questions/2190227/how-do-i-setup-nszombieenabled-in-xcode-4

首先,在Xcode中打开executables XXXX get info->Argument

在Argument卡设置四个参数

gdb命令:shell malloc_history pid address 或 info malloc-history address
用法 http://mobile.51cto.com/iphone-279455.htm 这里介绍很详细。

当问题解决后,要将NSDebugEnabled NSZombieEnabled MallocStackLogging 设置为无效,不需要删除变MallocStackLoggingNoCompact量,将变量前的对号去掉就可以了。


<==========================================================================>


xcode4以上的版本:Product -> Edit Scheme -> 右边框Diagnostic。

或:

Click the "Run Button Dropdown"
From the list choose Profile
The program "Instruments" should open where you can also choose Zombies
Now you can interact with your app and try to cause the error
As soon as the error happens you should get a hint on when your object was released and therefore deallocated.


As soon as a zombie is detected you then get a neat "Zombie Stack" that shows you when the object in question was allocated and where it was retained or released:
Event Type    RefCt     Responsible Caller
Malloc            1     -[MyViewController loadData:]
Retain            2     -[MyDataManager initWithBaseURL:]
Release           1     -[MyDataManager initWithBaseURL:]
Release           0     -[MyViewController loadData:]
Zombie           -1     -[MyService prepareURLReuqest]


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值