Re: Questions regarding release

2019-09-28 Thread Wim Lewis via Cocoa-dev
On Sep 2'6, 2019, at 9:47 AM, Gabr'iel Zachmann via Cocoa-dev wrote: >> >> I don’t believe that’s entirely true. “make” methods return a +0 value. >> >> The issue in the below code to my eye is that you allocate a path with >> CGPathCreateWithRect (+1) but then don't release it. >> > > In

Re: Questions regarding release

2019-09-27 Thread Gabriel Zachmann via Cocoa-dev
> > CGPathRef thePath = CGPathCreateWithRect( textlayer.bounds, NULL ); > textlayer.shadowPath = thePath; > CFRelease( thePath ); > Thanks a lot! that makes sense to me. Best regards, Gabriel smime.p7s Description: S/MIME cryptographic signature

Re: Questions regarding release

2019-09-27 Thread Mike Abdullah via Cocoa-dev
> On 27 Sep 2019, at 00:43, James Walker via Cocoa-dev > wrote: > > On 9/26/19 4:20 PM, Gabriel Zachmann via Cocoa-dev wrote: >>> The issue in the below code to my eye is that you allocate a path with >>> CGPathCreateWithRect (+1) but then don't release it. >>> >>> In that case, I am wonderi

Re: Questions regarding release

2019-09-27 Thread Gabriel Zachmann via Cocoa-dev
>> >> So, if I understand you correctly, I should do this: >> >> textlayer.shadowPath = CGPathCreateWithRect( textlayer.bounds, NULL ); >> CFRelease( textlayer.shadowPath ) >> >> ? >> Is that correct? > From a memory perspective, yes. This sounds to me like there could be other perspe

Re: Questions regarding release

2019-09-26 Thread Glenn L. Austin via Cocoa-dev
> On Sep 26, 2019, at 9:47 AM, Gabriel Zachmann wrote: > >> >> I don’t believe that’s entirely true. “make” methods return a +0 value. >> >> The issue in the below code to my eye is that you allocate a path with >> CGPathCreateWithRect (+1) but then don't release it. >> > > In that case, I a

Re: Questions regarding release

2019-09-26 Thread Rob Petrovec via Cocoa-dev
> On Sep 26, 2019, at 5:43 PM, James Walker via Cocoa-dev > wrote: > > On 9/26/19 4:20 PM, Gabriel Zachmann via Cocoa-dev wrote: >>> The issue in the below code to my eye is that you allocate a path with >>> CGPathCreateWithRect (+1) but then don't release it. >>> >>> In that case, I am wond

Re: Questions regarding release

2019-09-26 Thread James Walker via Cocoa-dev
On 9/26/19 4:20 PM, Gabriel Zachmann via Cocoa-dev wrote: The issue in the below code to my eye is that you allocate a path with CGPathCreateWithRect (+1) but then don't release it. In that case, I am wondering: doesn't ownership pass to the textlayer ? If yes, shouldn't textlayer release the p

Re: Questions regarding release

2019-09-26 Thread Rob Petrovec via Cocoa-dev
> On Sep 26, 2019, at 5:20 PM, Gabriel Zachmann via Cocoa-dev > wrote: > >> The issue in the below code to my eye is that you allocate a path with >> CGPathCreateWithRect (+1) but then don't release it. >> >> In that case, I am wondering: >> doesn't ownership pass to the textlayer ? >> If ye

Re: Questions regarding release

2019-09-26 Thread Gabriel Zachmann via Cocoa-dev
> The issue in the below code to my eye is that you allocate a path with > CGPathCreateWithRect (+1) but then don't release it. > > In that case, I am wondering: > doesn't ownership pass to the textlayer ? > If yes, shouldn't textlayer release the path when it gets destroyed by the > ARC? > > C

Re: Questions regarding release

2019-09-26 Thread John McCall via Cocoa-dev
On 26 Sep 2019, at 12:47, Gabriel Zachmann via Cocoa-dev wrote: I don’t believe that’s entirely true. “make” methods return a +0 value. The issue in the below code to my eye is that you allocate a path with CGPathCreateWithRect (+1) but then don't release it. In that case, I am wondering:

Re: Questions regarding release

2019-09-26 Thread Gabriel Zachmann via Cocoa-dev
> > I don’t believe that’s entirely true. “make” methods return a +0 value. > > The issue in the below code to my eye is that you allocate a path with > CGPathCreateWithRect (+1) but then don't release it. > In that case, I am wondering: doesn't ownership pass to the textlayer ? If yes, should

Re: Questions regarding release

2019-09-26 Thread Mike Abdullah via Cocoa-dev
I don’t believe that’s entirely true. “make” methods return a +0 value. The issue in the below code to my eye is that you allocate a path with CGPathCreateWithRect (+1) but then don't release it. Mike. > On 26 Sep 2019, at 17:16, Glenn L. Austin via Cocoa-dev > wrote: > > The analyzer is gre

Re: Questions regarding release

2019-09-26 Thread Glenn L. Austin via Cocoa-dev
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 <>< > On Sep

Re: Questions regarding release

2019-09-26 Thread Gabriel Zachmann via Cocoa-dev
> > 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

Re: Questions regarding release

2019-09-26 Thread Markus Spoettl via Cocoa-dev
On 9/26/19 11:16 AM, Gabriel Zachmann via Cocoa-dev wrote: NSImage * nsImage = [[NSImage alloc] initWithSize: nsimgrep.size]; [nsImage addRepresentation: nsimgrep]; return NSImage; You probably mean to write return nsImage; Best Regards Markus -- ___

Re: Questions regarding release

2019-09-26 Thread Gabriel Zachmann via Cocoa-dev
>> >>> Is the IOObjectRelease() right or wrong ? >> I’m not entirely sure since I can’t find the docs for >> IOServicePortFromCGDisplayID. > > Given that the code fragment shows it as a message being sent to “self”, this > looks like Gabriel’s own method. By the standard Obj-C clang naming

Re: Questions regarding release

2019-09-26 Thread Gabriel Zachmann via Cocoa-dev
Thanks a lot for your response. >> Is it safe to do it after assigning the nsimage to the layer, but before >> deleting the layer? > I would think so, but it is hard to say without knowing what > convertToNSImage:withOrientation actually does under the hood. It likely > either retains or

Re: Questions regarding release

2019-09-25 Thread Quincey Morris via Cocoa-dev
On Sep 25, 2019, at 13:52 , Rob Petrovec via Cocoa-dev wrote: > >> Is the IOObjectRelease() right or wrong ? > I’m not entirely sure since I can’t find the docs for > IOServicePortFromCGDisplayID. Given that the code fragment shows it as a message being sent to “self”, this looks like G

Re: Questions regarding release

2019-09-25 Thread Rob Petrovec via Cocoa-dev
> On Sep 25, 2019, at 2:52 PM, Rob Petrovec via Cocoa-dev > wrote: > >> Is it safe to do it after assigning the nsimage to the layer, but before >> deleting the layer? > I would think so, but it is hard to say without knowing what > convertToNSImage:withOrientation actually does under

Re: Questions regarding release

2019-09-25 Thread Wim Lewis via Cocoa-dev
On Sep 25, 2019, at 12:31 PM, Gabriel Zachmann via Cocoa-dev wrote: > The doc for CGImageSourceCreateImageAtIndex() that I need to release imageRef > myself. > Is it safe to do it after assigning the nsimage to the layer, but before > deleting the layer? Yes, the NSImage will retain/release

Re: Questions regarding release

2019-09-25 Thread Rob Petrovec via Cocoa-dev
> Is it safe to do it after assigning the nsimage to the layer, but before > deleting the layer? I would think so, but it is hard to say without knowing what convertToNSImage:withOrientation actually does under the hood. It likely either retains or copies it. In either case, your relea

Questions regarding release

2019-09-25 Thread Gabriel Zachmann via Cocoa-dev
A few years ago, I switched my code to ARC. Now, I have this in my code: CGImageRef imageRef = CGImageSourceCreateImageAtIndex( sourceRef, 0, NULL ); ... NSImage * nsimage = [self convertToNSImage: img withOrientation: img_orientation]; assign nsimage to a layer ... C