Re: Analyzer Questions
Re: Analyzer Questions
- Subject: Re: Analyzer Questions
- From: Jean-Daniel Dupas <email@hidden>
- Date: Tue, 2 Feb 2010 23:00:30 +0100
If for some reason you really want to use a naming convention that confuses the analyzer, you can also use the ns_returns_retained and cf_returns_retained clang attributes.
For details about these attributes (how to use them in a way that do not conflict with GCC), have a look at the following link:
http://clang-analyzer.llvm.org/annotations.html
Hopefully, new annotations will be added to the list so we can write our own retain/release wrapper without having lot of false positive.
Le 2 févr. 2010 à 22:14, Bob Barnes a écrit :
> 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 (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
>
-- Jean-Daniel
_______________________________________________
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