The analyzer is great at what it does but it can't be omniscient about your 
code.

When you start a method name with "make" or "new" or "create" it assumes that 
you're returning a +1 value.

--
Glenn L. Austin, Computer Wizard and Race Car Driver         <><
<http://www.austinsoft.com>

> On Sep 26, 2019, at 6:05 AM, Gabriel Zachmann via Cocoa-dev 
> <cocoa-dev@lists.apple.com> wrote:
> 
> 
>> 
>> The Xcode "analyze" step should check for errors of this kind. I have xcode 
>> set to analyze on every build, since it's usually not too slow.
> 
> Thanks a lot for the hint!
> 
> I tried it and it works pretty well.
> I actually found 2 (small) leaks.
> 
> There is one place in my code (different from my OP),
> where I get a "leaked" warning from the Analyzer, but I am not sure why that 
> is.
> 
> Here is what the function basically does:
> 
> - (void) makeTextLayerRectangle: (CATextLayer*) textlayer fontsize: (float) 
> fontsize text: (NSString*) text
> {
>   ...
>    textlayer.bounds = CGRectMake( 0.0, 0.0, string_rect.width, 
> string_rect.height );
>    textlayer.shadowPath = CGPathCreateWithRect( textlayer.bounds, NULL );
> }
> 
> 
> But I get the warning
> "Object leaked: allocated object of type 'CGPathRef _Nonnull' is not 
> referenced later in this execution path and has a retain count of +1"
> 
> Note that text layer is a call-by-reference var.
> 
> Is that just a bug in the Analyzer? Am I missing something?
> 
> Best regards, Gabriel
> 
> _______________________________________________
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/glenn%40austinsoft.com
> 
> This email sent to gl...@austinsoft.com

Attachment: signature.asc
Description: Message signed with OpenPGP

_______________________________________________

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

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

Reply via email to