• 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: Understanding objc_assign_strongCast
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Understanding objc_assign_strongCast


  • Subject: Re: Understanding objc_assign_strongCast
  • From: David Elliott <email@hidden>
  • Date: Thu, 7 Feb 2008 15:07:37 -0500

Hi Chris,

On Feb 7, 2008, at 12:50 PM, Christopher Nebel wrote:

On Feb 6, 2008, at 5:23 PM, Ben Trumbull wrote:

objc_assign_strongCast() will issue a write barrier, informing GC that the destination value has changed. But if the only references to this pointer are in unscanned (not GC) memory, than the GC system will think it's dead as no references to that pointer exist in scanned (GC live) memory.

The C++ new operator allocates from malloc(), just as before. malloc() memory is not GC scanned. It's probably easiest to instead use CFRetain and balance it with CFRelease in delete/etc.

You could also define a custom "new" operator for the class in question that allocates its memory using NSAllocateCollectable(..., NSScannedOption), but that might be more trouble than it's worth.



The problem then becomes: what references that object. Because obviously if that object doesn't have a strong reference, it will be considered finalizable and so will the other objects.


But yes, the thought crossed my mind and I'm sure I will find such a technique useful in the future.

-Dave

_______________________________________________

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


References: 
 >re: Understanding objc_assign_strongCast (From: Ben Trumbull <email@hidden>)
 >Re: Understanding objc_assign_strongCast (From: Christopher Nebel <email@hidden>)

  • Prev by Date: My app breaks when moved while running
  • Next by Date: Re: My app breaks when moved while running
  • Previous by thread: Re: Understanding objc_assign_strongCast
  • Next by thread: default expand outline view items
  • Index(es):
    • Date
    • Thread