• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSImage from bitmap - then delete bitmap
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage from bitmap - then delete bitmap


  • Subject: Re: NSImage from bitmap - then delete bitmap
  • From: Trygve Inda <email@hidden>
  • Date: Tue, 26 Jul 2016 19:46:07 -0700
  • Thread-topic: NSImage from bitmap - then delete bitmap

>
>> On 27 Jul 2016, at 10:05, Trygve Inda <email@hidden> wrote:
>>
>>>
>>
>> How is it retained by the main thread without an explicit retain call?
>
> are you not using ARC? If you are then all such references, both variable and
> during method calls are retained automatically. If you’re not, then do what
> ARC does and retain it explicitly and release it explicitly (and start using
> ARC in that case!)

This is non-ARC code. It is a large project and convertig to ARC is a huge
amount of work.

>>
>> I would be no different than a main thread calling:
>>
>> someVar [[MyObj alloc] init]
>> [someVar doSomething];
>
> That isn’t compilable code. Did you mean
>
> someVar = [ [ MyObj alloc]init ]
> [ someVar doSomething ];

Yes.

>
> Again if you’re using ARC, none of these issues are issues.
>
> Why would a worker thread call [ someVar release ] on a variable it didn’t
> retain in the first place? If that’s actually a realistic scenario and you’re
> not using ARC, then call retain on someVar when you assign it in the first
> place and release it only after you’re finished with it, after the call to
> doSomething. Which, by the way, is pretty much what ARC does.

I would think that even with a retain it could get weird...

The main thread wants to use the imageRef property so it calls:

myRef = [window.imageRef];
[myref retain];

If right between these calls, the worker thread calls setImageRef (on a
property with atomic, copy), then the retain call in the main thread might
be on something that has already gone away.

I just don't see how I can safely set the property on a worker thread and
read it on the main thread without some risk of it being released behind my
back.









_______________________________________________

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


  • Follow-Ups:
    • Re: NSImage from bitmap - then delete bitmap
      • From: Roland King <email@hidden>
References: 
 >Re: NSImage from bitmap - then delete bitmap (From: Roland King <email@hidden>)

  • Prev by Date: Re: NSImage from bitmap - then delete bitmap
  • Next by Date: Re: NSImage from bitmap - then delete bitmap
  • Previous by thread: Re: NSImage from bitmap - then delete bitmap
  • Next by thread: Re: NSImage from bitmap - then delete bitmap
  • Index(es):
    • Date
    • Thread