Finding Leaks Using Instruments

Finding Leaks Using Instruments

  The Instruments application can be used to find leaks in both OS X and iPhone applications.

  译:Instrument可以检测OSX和iOS程序的内存泄露。

  To find leaks, create a new document template in the application and add the Leaks instrument to it. The Leaks instrument provides leak-detection capabilities identical to those in the leaks command-line tool.

  译:Instrument Leak模板就是leaks命令行工具。

  The Leaks instrument records all allocation events that occur in your application and then periodically searches the application’s writable memory, registers, and stack for references to any active memory blocks. If it does not find a reference to a block in one of these places, it deems the block a “leak” and displays the relevant information in the Detail pane.

  译:Leaks记录所有的的内存分配,然后周期地根据当前变量可访问内存来检查内存泄露。

  In the Detail pane, you can view leaked memory blocks using Table. In Table mode, Instruments displays the complete list of leaked blocks, sorted by size. Selecting an entry in the table and clicking the arrow button next to the memory address shows the allocation history for the memory block at that address. Selecting an entry from this allocation history then shows the stack trace for that event in the Extended Detail pane of the document window. In Outline mode, the Leaks instrument displays leaks organized by call tree, which you can use to get information about the leaks in a particular branch of your code.

  需要注意,Instrument中Leaks 图像中没显示并不代码没有泄露,一切在tableview中为准。Leaks查内存泄露还是很准的,亲测。

原文地址:https://www.cnblogs.com/tekkaman/p/2921144.html