Re: Analyser reports memory leak… where?
Re: Analyser reports memory leak… where?
- Subject: Re: Analyser reports memory leak… where?
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 12 Sep 2013 16:31:07 -0400
On Sep 12, 2013, at 1:41 PM, Graham Cox <email@hidden> wrote:
> On 12/09/2013, at 6:57 PM, Bill Cheeseman <email@hidden> wrote:
>
> ....
>
>> The point remains, however, that the getter that started this thread returned an object retained, and the caller therefore owns it and is responsible for releasing it.
>
> There's an inherent contradiction in this statement. If it's a getter, then the caller has no responsibility for ownership of the returned object. If the caller does have that responsibility, then it's not a getter. In fact, -eventTypes in this case *is* a getter, or is intended to be.
The Advanced Memory Management Programming Guide I cited earlier says this about the Cocoa ownership rules, which I can't reconcile with your assertion that getters always leave the caller with no responsibility for ownership of the returned object.
"You can take ownership of an object using retain
"A received object is normally guaranteed to remain valid within the method it was received in, and that method may also safely return the object to its invoker. You use retain in two situations: (1) In the implementation of an accessor method or an init method, to take ownership of an object you want to store as a property value; and...."
I wonder if you are perhaps thinking of the Core Foundation Create Rule, which does say that a function named with "get" does not return a retained object (is returned by reference). If you can refer to any Cocoa documentation to the effect that getters never confer ownership in Cocoa, please pass it along.
--
Bill Cheeseman - email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden