Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Will this cause a leak?



On Jul 27, 2005, at 1:19 PM, Pontus Ilbring wrote:

On 7/27/05, Zameer Andani <email@hidden> wrote:

I'm a little confused with the concept of autorelease, I've read all the documentation about the topic that has been posted thus far in the forum and I find myself still confused. Can someone perhaps still clarify.


Then read all documentation over here as well:

http://www.cocoadev.com/index.pl?MemoryManagement

And also these two ASAP: http://www.stepwise.com/Articles/Technical/2001-03-11.01.html http://www.stepwise.com/Articles/Technical/HoldMe.html

I've said it many times, and I will say it again. Don't think directly of the retain count. Think of whether you (want to/should) own the thing or not. new/init/copy/retain and friends (initWith... etc) make you own it, release/autorelease decrease your ownership of it. The retain count of the object could be 2534 for all you care, as long as you've balanced your init/retain... with your release/ autorelease...
In the particular case of the autorelease that you were talking about, you just told the pool to retain the object while you release it at the same time, so this guarantees it will stick around at least until the pool flushes, but you can freely exit your method without worrying about it. Your job will have been done.


Haris


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Will this cause a leak? (From: "Zameer Andani" <email@hidden>)
 >Re: Will this cause a leak? (From: Pontus Ilbring <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.