在LLDB下排查message sent to deallocated instance问题
来源:互联网 发布:个性淘宝店名 编辑:程序博客网 时间:2024/05/17 06:10
最近在用MRC做一个测试项目,因为第一次用MRC,所以出现了很多问题,当我在用Analyze分析之后,就跟着它的提示改了,改了之后程序一运行就crash了,百度了之后才知道原来Xcode的Analyze也只是提示而已,并不一定是正确的。在出现内存泄露之后,我就各种百度,终于是找到LLDB下的解决方案。我看了很多都是gdb下的,但是Xcode7里面直接是LLDB的。不过终于找到了,测试过,但是没有测出来具体问题在哪里,不过这个方法还是挺有效的。
在XCode的以前版本中,如果遇到了
message sent to deallocated instance 0x6d564f0
我们可以使用info malloc-history 0x6d564f0来查看调用堆栈来查看崩溃发生的地方,这种方法这里不作阐述,大家自行百度。
在新的XCode里,调试器默认使用LLDB,我就讲一下如何在LLDB状态下定位到由于内存操作不当引起的Crash
首先我有一段会发生崩溃的代码:
NSString *themePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:themePathTmp];if(themePath) self.backgroundIV.image = [UIImage imageWithContentsOfFile:[themePath stringByAppendingPathComponent:@"mask_1.png"]];[themePath release];学过内存管理的人都应该知道在这里themePath并没有被retain,所以如果写了release,那么必然会发生崩溃情况。首先我们需要对开发的环境变量进行设置
运行代码,出现下面的崩溃现象
下面我们打开“活动监视器”,找到我们对应的PID,我们的Target为HPThemeManager,只要找到HPThemeManager对应的PID就可以(HPThemeManager是在论坛里下载的,本来正在看代码,就直接拿他来作试验了)
现在,我们得到了两个主要的信息:
进程ID:50127
崩溃地址:0x6d564f0
我们打开终端,输入以下命令:
sudo malloc_history 50127 0x6d564f0
结果显示为:
这样我们用能定位到这行代码
NSString *themePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:themePathTmp];
对themePath进行排查,就找到了崩溃的罪魁祸首
[themePath release];
虽然是这样,但是我还是没有找到,估计是泄露的地方太多了。不过这个博客还是可以看看的
0 0
- 在LLDB下排查message sent to deallocated instance问题
- 如何在LLDB下排查message sent to deallocated instance问题
- 如何在LLDB下排查message sent to deallocated instance问题
- 如何在LLDB下排查message sent to deallocated instance问题
- 如何在LLDB下排查message sent to deallocated instance问题
- 如何在LLDB下排查message sent to deallocated instance问题
- 排查message sent to deallocated instance问题
- 解决LLDB模式下出现message sent to deallocated instance错误
- message sent to deallocated instance问题的解决方法(gdb和lldb)
- message sent to deallocated instance问题的解决方法(gdb和lldb)
- Xcode做ios开发时 message sent to deallocated instance问题的解决方法(gdb和lldb)
- Xcode做ios开发时 message sent to deallocated instance问题的解决方法(gdb和lldb)
- message sent to deallocated instance问题的解决方法(gdb和lldb)
- message sent to deallocated instance问题的解决方法(gdb和lldb)
- Xcode做ios开发时 message sent to deallocated instance问题的解决方法(gdb和lldb)
- message sent to deallocated instance 0x7f9a6d85dca0 错误的排查
- message sent to deallocated instance
- message sent to deallocated instance
- 最大似然估计(MLE)与最大后验估计(MAP)
- 2015年大二上-数据结构-链表(1)-建立单链表
- 【lua】Lua中的table函数库
- Python练习册,第 0004 题
- XML
- 在LLDB下排查message sent to deallocated instance问题
- react-native编写过程遇到的问题及解决方法
- hdu4003 Find Metal Mineral
- 【ZJOI2008】【BZOJ1038】瞭望塔
- HYM8563驱动分析
- fiddler对android API接口抓包
- IOS开发基础Object-C(01)— OC概述及比较
- 2015多校第八场总结
- 总结----进程管理