Can some explain the retain cycles problem with a sample program?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Consider the following:
When
bis inserted intoa,bis retained, likewiseawhen its inserted intob. As both now have a strong reference to each other, neither will get deallocated unless you manually break the cycle by e.g. removing one from the other.Note that the Cocoa Memory Management guide also contains a section on retain cycles and includes an explanation of weak references, which help with these problems.