使用instrument查找EXC_BAD_ACCESS问题

You can see the malloc stack if you debug using instruments.

I encountered the same problem as you and similarly wanted to know how to get the malloc history when using lldb. Sadly I didn't find a nifty command like malloc-history found in gdb. To be honest I just switched my debugger over, but I found that annoying since I felt I shouldn't have to do that.

To find the malloc history using instruments:

  1. Profile your project
  2. Select Zombies from the list of instruments enter image description here
  3. Make your app trigger the problem
  4. At this point you should be presented with the address that was already deallocated and you can explore it. enter image description hereIt should be a simple matter of viewing the malloc history at this point. I blacked out portions that had class / project names specific to the work I'm doing, but I think the essence and usefulness of how to go about getting this information is present.

A Last Word

The problem I ran into yielded a message like:

* -[someClass retain]: message sent to deallocated instance 0x48081fb0 someProject(84051,0xacd902c0) malloc: recording malloc stacks to disk using standard recorder

I was really puzzled where this retain was coming from since the code it was breaking on didn't have one (not in the getter or setter of the line it was on). It turns out that I was not callingremoveObserver:forKeyPath: when a certain object was dealloc'ed. Later in execution KVO occurred do to a setter on a line and that blew up the program since KVO was trying to notify an object that was already released.

posted on 2012-11-02 17:20  kiao295338444  阅读(247)  评论(0编辑  收藏  举报

导航