Standard Memory Debugging Tools

This thread has been locked by a moderator.
In many cases I’ll be talking to folks with a memory management problem and I’ll say “You should investigate this with the standard memory debugging tools.” They then turn around and ask me “What are those tools?” Well, this is what I mean:
  • Zombies — This lets you quickly detect when an object is used after it has been deallocated. You can learn more about it in the Finding zombies section of the Instruments Help. There was also an excellent WWDC video about this, namely, WWDC 2010 Session 311 Advanced Memory Analysis with Instruments. Unfortunately this is no long available in the video archive, but if you can find a copy it’s well worth a watch.

  • Address Sanitizer — This is a lower-level tool that finds a variety of common memory management issues, including use after free and buffer overruns. You can learn more about this in the Address Sanitizer article. There’s also a good discussion of this tool, and other Xcode runtime diagnostic tools, in WWDC 2017 Session 406 Finding Bugs Using Xcode Runtime Tools.

  • Older tools — There’s a variety of older tools that might be useful in some specific circumstances. See the Enabling the Malloc Debugging Features section of the Memory Usage Performance Guidelines for more information about these. Of specific interest is libgmalloc, which is documented in a UNIX man page.

For some practical examples of how to identity a memory management crash report and then investigate that crash with these tools, take a look at WWDC 2018 Session 414 Understanding Crashes and Crash Logs.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + ""

  • 16 Nov 2017 — First posted.

  • 2 Nov 2018 — Updated to include a reference to WWDC 2018 Session 414 Understanding Crashes and Crash Logs.

  • 22 Jan 2019 — Fixed the link to libgmalloc.

  • 30 Oct 2019 — Removed the link to WWDC 2010 Session 311 Advanced Memory Analysis with Instruments because it’s not long available in the archive. Refreshed all the other links.

  • 23 Oct 2020 — Fixed some formatting errors.

Up vote post of eskimo