Monday January 21, 2013

A Great Case Study of Retain Cycles, ARC, and Blocks

Conrad Stoll wrote up an excellent real-world example of how Objective-C blocks + ARC can cause a lot of confusion about memory leaks through retain cycles. A compiler warning recommended the wrong thing that led to an image processing operation retaining a block that retained the operation.

In the past, we had to remember the rules about object ownership and balance calls to retain/release. In the new world, the balance is maintained for us but we have new rules to declare the balance. Hopefully the next step in this memory management evolution won’t feel so much like we just shuffled papers around.