"Ownership follows the 'Create' Rule'" - not literally
"Ownership follows the 'Create' Rule'" - not literally
- Subject: "Ownership follows the 'Create' Rule'" - not literally
- From: Jerry Krinock <email@hidden>
- Date: Fri, 23 Aug 2013 21:13:40 -0700
OS X app, manual retain/release.
According to 'leaks' with MallocStackLoggingNoCompact, I was leaking a CFData object when I called CFMessagePortSendRequest().
Indeed, the last parameter of CFMessagePortSendRequest() returns a CFData object by reference, and the documentation states that "Ownership follows the 'Create Rule'" for this parameter. When I wrote this code, I read the Create Rule, looked at the name "CFMessagePortSendRequest", did not see the word "Create" or "Copy" and so said, "that CFData is not mine to release".
Now, faced with the leak, I added a -release when I was done with that CFData, and tested with MallocScribble and MallocPreScribble environment variables set to 1. Result: No more leak, no crashes.
Lesson: When documentation says that "Ownership follows the 'Create Rule'" for a parameter, what they really mean to say is that "When applying the 'Create Rule' to this function, proceed as though this function had 'Create' in its name". Or, more succinctly, "You own this object".
_______________________________________________
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