Closure capture cycles
A messaging app's ViewModel keeps a completion closure in a property for a long time, and inside it updates self.messages. What reference graph creates the retain cycle?
A messaging app's ViewModel keeps a completion closure in a property for a long time, and inside it updates self.messages. What reference graph creates the retain cycle?
The ViewModel holds the closure strongly through a property, and the closure captures self strongly the moment its body uses self.messages, so the arrow from ViewModel to closure and the arrow from closure back to ViewModel form a loop and neither can be freed.
Memory and ARCMultiple choiceBasics
Which of these two snippets creates a reference cycle? …
#retain-cycle #weak-self
Memory and ARCShort answerBasics
Give me a concrete code example that creates a retain cycle, and fix it.
#retain-cycle #weak-self
Memory and ARCShort answerIntro
What is ARC, and why do we need it?
#arc
Memory and ARCShort answerBasics
A view controller doesn't seem to leave memory after you close its screen. How would you…
#retain-cycle