Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

iOS — Identifying Memory Leaks using the Xcode Memory Graph Debugger

Pete Smith
Zendesk Engineering
3 min readApr 20, 2017

--

In this short post I describe,

  • What the Xcode memory graph debugger is
  • How to use it, and some tips
  • It’s pros/cons

What is it

TL;DR: In one sentence, the memory graph debugger helps to answer the following question: Why does an object exist in memory?

The Xcode memory graph debugger helps find and fix retain cycles and leaked memory. When activated, it pauses app execution, and displays objects currently on the heap, along with their relationships and what references are keeping them alive.

How to use it

3 quick steps to identifying retain cycles and memory leaks:

  • #1. Opt in to stack logging integration via the Xcode scheme editor, as follows:
Enable Malloc stack logging for live allocations

Note that we only enable logging of ‘Live Allocations’. This has a lower overhead than ‘All Allocations’ when debugging, and is all we need to identify retain cycles and leaks.

  • #2. Perform whatever app actions you want to analyse (the actions you suspect are causing retain cycles and leaks), and enter memory graph debugging mode by selecting its debug bar button:
  • #3. The memory graph debugger…

--

--