Skip to content
Commitwise
Menu

Retain cycle

Also called: Reference cycle, Strong reference cycle

Two or more objects holding strong references to each other, so none of them is ever freed.

Definition

A retain cycle is the most common memory leak under reference counting. Each object keeps the other alive, so their counts never drop to zero even when nothing else uses them. Mark one side of the relationship as weak (or capture [weak self] in closures) to break it.

In practice

A parent view controller owns a child, and the child keeps a strong delegate reference back to the parent. Closing the screen leaks both.

Learn it in context

Lessons that use this term.

Related terms

Esc

Type to search the whole site.