Member-only story
SEE Retain Cycles in Xcode
Xcode has a Visual Memory Debugger!
It can be difficult tracking down retain cycles in Xcode. This is the article (with example) to help you to use this great feature!
Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 11.5, and Swift 5.2.4
Prerequisites:
- You need to either be able to make a Single View Application in Swift
- This projection uses Optionals and Classes
The issue
Retain cycles can cause memory leaks. If a root object creates a group of objects that hold onto each other with strong references, and later that group is released it cannot be freed with memory.
This is because reference counting is used, and every time a reference is deleted the count decreases by one and an object can only be released when the reference count for that object is zero.
A reference cycle means the reference count can never reach zero, and objects cannot be released and this causes a memory leak — which means that the memory used is never released back for use in the system.