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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to