Search code examples
objective-cxcodedebuggingmemory-leaksinstruments

Understanding Instruments in Xcode, testing for leaks


I just started using Instruments, a nice little tool for testing memory allocations/ leaks and all that great stuff. But I'm pretty confused at how it works... Ive looked for tutorials explaining how to work with it, but no tutorials explained what to do with it.

I'll try to explain this: I have it set up to whenever I run my Xcode app, Instruments tracks everything. But the stuff that instruments record makes no sense to me.

There was one leak discovered, and after that it started leaking bytes. It says the leaked object is _NSCFString and some other stuff like that. Here is a screenshot

enter image description here

My question is, how do I interpret this? If there is a tutorial out there that explain this, please leave as an answer, or explain it to me.


Solution

  • The best way to learn how to use Instruments is to watch the iOS/macOS Development Essential/Advanced/Foundation videos as well as the WWDC session videos on the topic.

    You can find a list at past WWDC Session Videos to watch. They do not require a developer account to access.

    iPhone Foundation Development Videos:

    • Session 916 - Getting Started with Instruments

    WWDC 2009:

    • Session 414 - iPhone Performance Optimization with Instruments

    WWDC 2010:

    • Session 304 - What's New in Instruments
    • Session 306 - Automating User Interface Testing with Instruments
    • Session 309 - Advanced Performance Analysis with Instruments
    • Session 311 - Advanced Memory Analysis with Instruments

    WWDC 2011:

    • Session 310 - What's New In Instruments
    • Session 312 - iOS Performance and Power Optimization with Instruments

    WWDC 2012:

    • Session 409 - Learning Instruments

    WWDC 2014:

    • Session 418 - Improving Your App with Instruments

    WWDC 2015:

    • Session 412 - Profiling in Depth

    WWDC 2016:

    • Session 411 - System Trace in Depth
    • Session 418 - Using Time Profiler in Instruments

    WWDC 2018:

    • Session 405 - Measuring Performance Using Logging
    • Session 407 - Practical Approaches to Great App Performance
    • Session 410 - Creating Custom Instruments

    WWDC 2019:

    • Session 411 - Getting Started with Instruments
    • Session 414 - Developing a Great Profiling Experience
    • Session 421 - Modeling in Custom Instruments

    2020 Tech Talks:

    • Demystify and eliminate hitches in the render phase
    • Find and fix hitches in the commit phase