• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
"Ownership follows the 'Create' Rule'" - not literally
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"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


  • Follow-Ups:
    • Re: "Ownership follows the 'Create' Rule'" - not literally
      • From: "Stephen J. Butler" <email@hidden>
    • Re: "Ownership follows the 'Create' Rule'" - not literally
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: NSWindow setMinSize: jumps up to current size instead
  • Next by Date: Re: Audio in WebView stop when close NSWindow
  • Previous by thread: Re: Using CGContext as a graphics state object
  • Next by thread: Re: "Ownership follows the 'Create' Rule'" - not literally
  • Index(es):
    • Date
    • Thread