Retain cycles and Xcode Instruments: fun or frustration?
My past weekend was full of running the Leaks instrument within Xcode to battle
a nasty retain cycle in RocketSim. I've been using the Memory Graph Debugger in Xcode, searched the web for AppKit related solutions, but had difficulty finding out the cause.
Eventually, I found
the solution, which resulted in
a graph that I liked much more.
I'm not here to explain to you how Xcode Instruments can be used (expect an article on that later 😉 ), but instead how I found out the cause eventually!
Like filing bug reports to Apple, I created a new Xcode project isolating the issue. It allowed me to zoom into the code causing the retain cycle, and it helped me narrow down the problem to the single masking layer.
If you're having trouble finding the cause of a bug, it might be good to reproduce the issue within a separate Xcode project to take away assumptions and ensure no unseen side effects are causing your problem.
Enjoy this week's SwiftLee Weekly!