Finding Memory Leaks in Your App

Use the Leaks instrument of the Instruments analysis tool to find objects in your app that are no longer referenced and reachable.

To find memory leaks in your app
  1. Open the Leaks template.

  2. Choose your app from the Choose Target pop-up menu.

  3. Click the Record button.

  4. Exercise your app to execute code, and click Stop when leaks are displayed.

  5. Click any leaked object identified in the Detail pane.

  6. Within the Extended Detail pane, double-click an instruction from your code.

  7. In the Detail pane, click the Xcode icon to open that code in Xcode.

Click the Leaks instrument in the Instruments pane to display leaks in the Detail pane. The Leaks graph shows you the number of leaks and total leaked bytes.

The screenshot shows the Allocations and Leaks instruments recording the CalcLeaks app, with a malloc leak selected in the Detail pane and the stack trace for that leak in the Extended Detail pane.