• 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: Ben Trumbull <email@hidden>
  • Date: Wed, 6 Feb 2008 17:23:43 -0800

Dave,

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.

In fact, I've written some pretty hairy hybrid memory model code, and have yet to find a use for calling objc_assign_strongCast() myself.

The GC programming guide talks about using CFRetain/CFRelease in the section on Core Foundation objects. The primary difference with C++ objects is that C++'s new is from unscanned malloc memory where as CF types (with the default allocator) are allocated from scanned memory.
--


-Ben
_______________________________________________

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: Understanding objc_assign_strongCast
      • From: Christopher Nebel <email@hidden>
    • Re: Understanding objc_assign_strongCast
      • From: David Elliott <email@hidden>
  • Prev by Date: Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful
  • Next by Date: Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful
  • Previous by thread: Understanding objc_assign_strongCast
  • Next by thread: Re: Understanding objc_assign_strongCast
  • Index(es):
    • Date
    • Thread