In this question, I asked about the following code and retain cycles:
__weak Cell *weakSelf = self;
NSBlockOperation *op = [NSBlockOperation blockOperationWi
Your old code creates this retain cycle if you don't use __weak
:
(NSBlockOperation *)op
retains the outer blockself
(if you're not using __weak
)self
retains (NSOperationQueue *)renderQueue
(NSOperationQueue *)renderQueue
retains (NSBlockOperation *)op
None of the objects in that cycle can be deallocated unless one of those links is broken. But the code you showed us does break the retain cycle. When op
finishes executing, renderQueue
releases it, breaking the retain cycle.
I suspect that your new code creates this retain cycle:
(MBItem *)close
retains the blockself
self
retains childObject
childObject
retains (NSMutableArray *)items
(NSMutableArray *)items
retains (MBItem *)close
If nothing happens to break one of those links, none of the objects in the cycle can be deallocated. You haven't shown us any code that breaks the retain cycle. If there is no event that explicitly breaks it (for example by clearing out childObject.items
), then you need to use __weak
to break the retain cycle.