David,

   Thanks, changing several methods to use the 'new..." naming standard did the 
trick. Using create as suggested by Wade didn't fix the problem, which explains 
why another method (createBitmapContext) was showing similar behavior. 

Bob


On Feb 2, 2010, at 12:18 PM, David Duncan wrote:

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

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

Reply via email to