Xcode调试之exc_bad_access以及 message sent to deallocated instance
如果出现exc_bad_access错误,基本上是由于内存泄漏,错误释放,对一个已经释放的对象进行release操作。但是xcode有时候不会告诉你错误在什么地方(Visual Studio这点做得很好)。不过我们可以通过设置xcode环境变量环境变量NSZombieEnabled,MallocStackLogging查看错误的来源:
1、菜单 Product > Manage Schemes;
2、选中当前的Scheme,点Edit按钮;
3、设置环境变量。在Arguments > Environment Variables;
4、添加环境变量MallocStackLogging,NSAutoreleaseFreedObjectCheckEnabled,MallocStackLoggingNoCompact,NSZombieEnabled并设置YES
5、最后记得把环境变量删除或设置为NO,因为它们会使得内存不会被释放.
message sent to deallocated instance后会有一个内存地址,如:0×6497860,我们需要查看该地址的malloc history.查看方法,在原来的gdb下,使用”info malloc_history 0×6497860“即可显示malloc记录。但是新版的Xcode 不再支持,怎么办呢?秀逗麻袋,我们还有terminal,使用终端的malloc_history命令,如”malloc_history 32009 0×6497860“或者“sudo malloc_history 32009 0×6497860”即可显示。其中的32009是该进程的pid,根据这个malloc记录,可以大致定位出错信息的代码位置。
会出现类似以下提示代码,根据提示就可以找出错误具体位置
ALLOC 0xfcdff50-0xfce00b7 [size=]: thread_3bf2a28 |start | main | UIApplicationMain | GSEventRun
| GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoObservers
| __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ | _afterCACommitHandler | _applyBlockToCFArrayCopiedToStack
| ___afterCACommitHandler_block_invoke | __38-[UITableView touchesEnded:withEvent:]_block_invoke |
-[UITableView _userSelectRowAtPendingSelectionIndexPath:] | -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] | -[MessageListViewController tableView:didSelectRowAtIndexPath:] | _objc_rootAlloc | class_createInstance | calloc | malloc_zone_calloc
Xcode调试之exc_bad_access以及 message sent to deallocated instance的更多相关文章
- iOS内存错误EXC_BAD_ACCESS的解决方法(message sent to deallocated instance)
iOS开发,最郁闷的莫过于程序毫无征兆地就崩溃了,用bt命令打出调用栈,给出的是一堆系统EXC_BAD_ACCESS的信息,根本没办法定位问题出现在哪里.通常这样的崩溃出现,原因一般就是:调用了已经释 ...
- 解决LLDB模式下出现message sent to deallocated instance错误
本文在源文的基础上做整理:http://www.devdiv.com/home.php?mod=space&uid=50901&do=blog&id=50856 Xcode版本 ...
- 如何在LLDB下排查message sent to deallocated instance问题
转:http://www.devdiv.com/home.php?mod=space&uid=50901&do=blog&id=50856 在XCode的以前版本中,如果遇到了 ...
- message sent to deallocated instance
在XCode的以前版本中,如果遇到了 [代码]c#/cpp/oc代码: 1 message sent to deallocated instance 0x6d564f0 我们可以使用info mall ...
- 捉襟见肘之message sent to deallocated instance 0x16f62a70
出现的问题(真机ios8到ios9测试没有问题,真机ios7.1出现问题): -- :::60b] *** -[ChatViewController scrollViewDidScroll:]: me ...
- [UIImage _isCached]: message sent to deallocated instance
本文转载至 http://zhuhaibobb.blog.163.com/blog/static/2744006720124191633375/ 这几天做了个APP打开20份钟左右就强制退 ...
- runtime MethodSwizzle 实践之 奇怪crash : [UIKeyboardLayoutStar release]: message sent to deallocated instance
情景: 使用MethodSwizzle 实现对数组.字典 等系统方法的安全校验.显然能达到预期效果,但实际发现当 键盘显示的情况下 home app 进入后台,再单击app 图标 切换回前台时 发 ...
- UICollectionView [NSIndexPath section]: message sent to deallocated instance
在UICollectionView上加UITapGestureRecognizer手势时,点击哪都报 [NSIndexPath section]: message sent to deallocate ...
- [CALayer release]: message sent to deallocated instance iOS内存过度释放问题
[CALayer release]: message sent to deallocated instance iOS内存过度释放问题 解决方式: 1:先找到过度释放的 内存指针 开启-僵尸模式:xc ...
随机推荐
- Self-examination
第一次参加省赛,算是真正感受到比赛的残酷.拿到好成绩,需要平时大量的积累,甚至也需要一点运气,然后我还做的不够,但我觉得我可以做得更好. 我之前是没有任何基础,大一才刚刚从知码开门入门.然后刚开始一直 ...
- form中采用图片作为提交按钮
<span style="font-size:14px;"><FORM name="formName" action="xxxx&q ...
- [LC] 105. Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that ...
- 吴裕雄--天生自然 HADOOP大数据分布式处理:修改CenterOS 7 IP设置
- mysql安装后,进DOS输入命令mysql,提示错误:mysql ERROR 1045 (28000)的解决办法
一.修改my.ini文件,并重启mysql服务 找到配置文件my.ini ,然后将其打开,可以选择用记事本打开 打开后,搜索mysqld关键字,找到后,在mysqld下面添加skip-grant-t ...
- Longest Increasing Subsequence (Medium)
第一次做题思路201511092250 1.采用map存储,key为nums[i],value为以nums[i]为结尾的最大递增子序列的长度 2.采用map里面的lower_bounder函数直接找出 ...
- Qt 添加Includes、Libraries库
1 #------------------------------------------------- # # 加载相机SDK-Includes-Libraries # #------------- ...
- js - 常用的继承
零.序言 参考资料:JavaScript常用八种继承方案: 注:1.此篇笔记是站在上述资料的肩膀上的一篇小结: 2.阅读之前建议温习一下 js 中的 prototype 和 constructor:( ...
- 思科WLC5508上传定制Portal展示模版
1. 登录Cisco设备,获取模板样例登录cisco WLC设备后点击help,打开帮助文档Wireless Tab-->Web Login Page-->External Web Aut ...
- 吴裕雄--天生自然 R语言开发学习:中级绘图
#------------------------------------------------------------------------------------# # R in Action ...