I'm developing a custom iOS SDK. I'm creating weak, strong references based on my requirement. What is not clear to me is: when will the weakly reference object gets de-allocated?
Assume I have 3 objects A,B,C
. A
has a weak reference to B
and B
has strong reference to C
.
A --- >(weak ref) B --->(strong ref)C
. All the 3 objects are In-memory objects. Since B
does not have any strong references to it, it may get de-allocated. Once B
is deallocated, C
object memory leaks.I cant have strong ref from "c" back to "B" to prevent it from getting de-allocated as it may cause retain cycles. How will ARC takes a decision to de-alloc B
? I do understand that objects will be deallocated immediately when the last strong reference to them goes away.But there is no objects strongly refering to "B" at any cause.In this case,When will B gets de-allocated?.