How to Stop Memory Leaks - Helpful Resources


#1

Recently I answered some questions regarding memory leaks in Swift and iOS.

If you’re running into problems that probably means it’s time for you to learn how to use some of the tools built into Xcode to help spot bugs you might not see.

I’ve used all of these tools in my previous apps, and on my contract jobs to quickly spot bugs that would have caused issues later on.

Apple has some great videos to watch, which will give you insight into how the tools work, and then I would recommend applying them to your existing app to see what you can uncover.

These tools allow you to become the detective on a search for memory leaks and random behavior.

If you don’t know if you have memory leaks yet, make sure you watch the Improving Your App with Instruments video to get an overview of how to get started.

  1. Videos on Instruments

    1. Debugging with Xcode 9 (2017)
    2. Improving Your App with Instruments (2014)
    3. Using Time Profiler in Instruments (2016)
    4. System Trace in Depth (2016)
  2. Thread Sanitizer and Static Analyzer

    1. Thread Sanitizer and Static Analysis (2016)
    2. Finding Bugs Using Xcode Runtime Tools (2017)
  3. Memory leaks using the sanitizers in Xcode Scheme settings

    1. I believe that both the Static Analyzer and the Memory Management Santizers from the Scheme settings will help you track down the problems.
  4. Here’s another interesting post: https://medium.com/@xcadaverx/locating-the-source-of-a-memory-leak-712667bf8cd5

Don’t let the video publication dates scare you, but keep in mind the tools evolve over time. Watching older Apple videos is incredibly useful.

I tend to watch these on my iPad on the couch 1x, and then I’ll watch it again when I try to follow along.