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.
Videos on Instruments
Thread Sanitizer and Static Analyzer
Memory leaks using the sanitizers in Xcode Scheme settings
- I believe that both the Static Analyzer and the Memory Management Santizers from the Scheme settings will help you track down the problems.
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.