On Feb 2, 2010, at 11:58 AM, Bob Barnes wrote:

>   I've recently upgraded to Mac OS X 10.6.2 in order to run the Analyzer for 
> Xcode and it's pointing out some potential memory leaks that really have me 
> confused. A typical example is where I have a method that allocates and 
> returns something like a CGPDFDocumentRef or CGContextRef. The analyzer 
> reports that  the object allocated and stored in the variable is potentially 
> being leaked, however, if I call the appropriate release, such as 
> CGPDFDocumentRelease or CGContextRelease in the calling method it's reported 
> as an incorrect decrement of an object not owned by the caller. 


The analyzer checks the standard Cocoa/CF ownership model. In short it is 
reporting that a "getter" method (that returns a non-owned instance) is 
returning an owned instance, which it believes may be a memory leak (because 
the caller is not expected to release the object). Similarly it is reporting 
that a method is releasing an object that it does not own (because the method 
used a "getter" to get the object).

Basically, your code doesn't conform to the standard ownership model, which is 
confusing the analyzer. If you renamed your method to "newPDFDocumentRef" then 
the analyzer wouldn't give you either error, as this would be in line with the 
standard ownership model.
--
David Duncan
Apple DTS Animation and Printing

_______________________________________________

Cocoa-dev mailing list ([email protected])

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

This email sent to [email protected]

Reply via email to