0 Replies
      Latest reply on Jan 22, 2019 1:44 AM by eskimo
      eskimo Apple Staff Apple Staff (11,625 points)

        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’s also an excellent WWDC video about this, namely, WWDC 2010 Session 311 Advanced Memory Analysis with Instruments.  I can’t link to it directly but you can find it in the archive.

        • 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" + "@apple.com"

        Updates:

        • 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.