• 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
Re: Should the analyzer catch retained objects returned from createXXX methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should the analyzer catch retained objects returned from createXXX methods?


  • Subject: Re: Should the analyzer catch retained objects returned from createXXX methods?
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 17 Aug 2011 16:22:36 -0500

On Aug 17, 2011, at 4:06 PM, Rick Mann wrote:

> I have a method named createFoo, from which I return an object with a retain count of 1. The Xc4 static analyzer is complaining about a potential leak, but I thought it would notice the "create" in the name...

"Create" in a name is a Core Foundation convention, not a Cocoa convention.  This is specifically called out in the Memory Management Programming Guide <http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html>:

> Important: There are similar memory management rules for Core Foundation objects (see Memory Management Programming Guide for Core Foundation). The naming conventions for Cocoa and Core Foundation, however, are different. In particular, Core Foundation’s “create rule in Memory Management Programming Guide for Core Foundation” does not apply to methods that return Objective-C objects. For example, in the following code fragment, you are _not_ responsible for relinquishing ownership of myInstance:
>
> MyClass *myInstance = [MyClass createInstance];

Regards,
Ken

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Should the analyzer catch retained objects returned from createXXX methods?
      • From: Bill Cheeseman <email@hidden>
References: 
 >Should the analyzer catch retained objects returned from createXXX methods? (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Should the analyzer catch retained objects returned from createXXX methods?
  • Next by Date: Re: serious problems in GDB / LLDB debugger
  • Previous by thread: Re: Should the analyzer catch retained objects returned from createXXX methods?
  • Next by thread: Re: Should the analyzer catch retained objects returned from createXXX methods?
  • Index(es):
    • Date
    • Thread