Skip to content
Preptima
mediumConceptScenarioMidSenior

How do retain cycles happen in Swift closures and delegates, and how would you find one in an app that is slowly leaking memory?

4 min readUpdated 2026-08-15

Answer

Short answer

A closure or delegate reference that captures its owner strongly, while the owner also holds that closure or delegate strongly, forms a cycle ARC cannot break on its own, and the fix is weak or unowned capture chosen by lifetime, not by habit.

Was this answer helpful?

Likely follow-ups

  • Why does delegate almost always need to be declared weak var even when the protocol is a class-only protocol?
  • What is the difference between how a retain cycle presents in the Memory Graph Debugger versus a genuine one-off leak?
  • Why is unowned dangerous specifically when the closure can outlive the object it captures?
  • How does a capture list interact with a closure that is stored as a property versus one that is passed and executed immediately?

Related questions

Further reading