How To Debug Memory Leaks with XCode and Instruments Tutorial 边读边记

来源:互联网 发布:淘宝警察钱包 编辑:程序博客网 时间:2024/05/17 03:24

How To Debug Memory Leaks with XCode and Instruments Tutorial

大神还有一些advise,赶紧记录一下,不禁长叹一声,早就该看如此好文了。相见恨晚啊

Here’s the advice I generally give to developers when you hit an EXC_BAD_ACCESS error:

  1. Set the NSZombieEnabled argument in your executable options, which sometimes helps narrow down the cause
  2. Run with Apple Instruments such as Leaks to look for memory issues
  3. Set a breakpoint in your code and step through until you narrow down where it’s crashing
  4. Tried and true “comment out code till it works” then backtrack from there :]
夜已深,先睡了。
现在是第二天,奇怪,我的Instruments看到的情况跟教程里面提到的不一致,尤其是,没有显示那个函数,不知道为什么?暂时把这个问题挂起吧,我的版本是Xcode把嫩是 Version 4.4.1 (4F1003),我觉得不是版本的原因。

Let’s try it out. Go to Run\Run with Performance Tool\Leaks, and select a few rows in the table view. Also scroll up and down the table view from the top of the table to the bottom of the table. After bait of experimentation, you should start seeing some leaks popping up in the Leaks tab, which show up as blue bars.

Click the stop button, then go to the toolbar in the middle and click it to change from “Leaked Blocks” to “Call Tree”. In the panel in the lower left, click “Invert Call Tree”, and “Hide System Libraries”. You’ll see that it found two different methods in the code with memory leaks, as you can see below:

我没有看到blue bars,后面也没看到到这this two  methods