调试Iphone程序接收信号:“EXC_BAD_ACCESS” [英] Debug Iphone Program received signal: "EXC_BAD_ACCESS"

查看:140
本文介绍了调试Iphone程序接收信号:“EXC_BAD_ACCESS”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iphone应用程序随机收到这个消息。我知道这是内存释放问题。然而,找到哪个对象导致此问题的最佳方法是什么?这是我尝试过的


  1. 使用仪器泄漏和
    ObjectAllocation Trace。没有看到任何
    帮助知道哪个对象有这个
    问题


    1. 放NSZombieEnabled = YES和项目执行官...没有看到任何
      帮助


    2. 将NSLog放在任何地方,但EXE_BAD_ACCESS只是出现在任何地方。
      在调试器中,刚刚看到代码
      发生在程序集中。像
      objc-msg send。


    3. 多次查看代码,读取内存管理很多时间
      ,并在线研究了很多时间。但
      没有惊喜。


    是否有一个完整的解决方案来解决这个问题。我是一个以前的Visual C ++程序员,我处理多年的内存管理,它很容易调试,并在Visual C ++中找出。



解决方案

正如Juan所说,第一个停止是Debugger - 当应用程序崩溃时,调试窗口为堆栈跟踪提供什么?你应该可以看到它崩溃的线路...你在一个回应中说,你看到崩溃发生在以下行:

  CGPDFDocumnetRef docA = CGPDFDocumentCreatWithURL(myurl); 
CGPDFDocumnetRef docB = CGPDFDocumentCreatWithURL(myurl);

您是否对两个通话使用相同的URL对象?哪一行是正确的?



这可能是您使用CGPDFDocumentRef的方式,您可以在QuartzDemo项目中找到Apple如何使用它们的示例代码QuartzImageDrawing.m(您可以从开发人员门户找到演示项目,或使用XCode嵌入到iPhone文档中)。



XCode实际上功能非常强大,但它与其他IDE的区别。


My iphone app randomly received this message. I know certain it is memory release problem. However what is the best way to find which object leads this problem. Here are what I have tried

  1. Use Instrument Leak and ObjectAllocation Trace. Dont saw any help to know which object have this problem

    1. Put NSZombieEnabled=YES and project executive ... Dont saw any help either

    2. Put NSLog everywhere but the EXE_BAD_ACCESS just appear anywhere. in the debuger, just saw the code happened in the assembly. like objc-msg send.

    3. review code many times and read memory management a lot time and research online a lot time. but no surprise.

    Is there a completed solution to figure out this problem easily. I am a previous Visual C++ programmer, I deal with memory management with years and it is easy to debug and figure out in Visual C++.

解决方案

As Juan noted, the first stop is the Debugger - what does the debug window give for a stack trace when the app crashes? You should be able to see the line it crashed on... you said in a comment to one response that you saw the crash happen around the lines:

CGPDFDocumnetRef docA=CGPDFDocumentCreatWithURL(myurl);
CGPDFDocumnetRef docB=CGPDFDocumentCreatWithURL(myurl);

Are you really using the same URL object for both calls? Which line is it exactly?

It could be something around the way you make use of the CGPDFDocumentRef, you can find example code how Apple uses them in the QuartzDemo project, file "QuartzImageDrawing.m" (you can find the demo project from the developer portal or embedded in the iPhone documentation with XCode).

XCode is actually pretty powerful, but it does things differently from other IDE's.

这篇关于调试Iphone程序接收信号:“EXC_BAD_ACCESS”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆