In this Apple code: http://developer.apple.com/library/ios/#qa/qa1702/_index.html
I can see that the session allocated at the start of the init method is not released.
Why ? Is there a reason to this ?
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.
A couple possible reasons come to mind:
autoreleasecall later in the same snippet.sessionat the end of theinitmethod is declared@property (assign), and so they deliberately wanted to keep it retained for now. If I remember right, this is poor practice – they should haveautoreleased session and declared the@property (retain).releasethesessionlater. Not strictly poor practice, but certainly confusing and hard to read, and may lead to a bug in maintenance later (when someone loses track of theretain–releasebalance).In any event, you’re right in that it’s somewhat inconsistent with good memory management practices. It’s hard to tell for sure, however, whether there’s a definitive reason it’s not released.