On Jun 28, 2009, at 4:12 PM, Michael Ash wrote:

On Sun, Jun 28, 2009 at 1:17 PM, Quincey
Morris<quinceymor...@earthlink.net> wrote:
I think the answer is in Bill's "entirely", above.

Without CFMakeCollectable, the final CFRetain will trigger the calling of (a hypothetical) CFDispose with the traditional timing (i.e. immediately, we
assume, somewhat at our peril).

[...] Thus GC-unaware code gets the behavior at CFRelease time that it expects
(somewhat at its peril), whether or not it is running in a GC-enabled
environment.

"If the object is in the garbage collected zone, the last CFRelease()
does not immediately free the object, it simply makes it eligible to
be reclaimed by the collector when it is discovered to be
unreachableā€”that is, once all strong references to it are gone. Thus
as long as the object is still referenced from an object-type instance
variable (that hasn't been marked as__weak), a register, the stack, or
a global variable, it will not be collected."

From the Garbage Collection Programming guide.

Your way sounds sensible, but according to the docs that's not how it is.

Maybe I'm misreading one, or the other, or both of your messages, but it seems to me that what Quincy wrote is in agreement with what you quoted.

In particular, my (admittedly inexperienced) understanding is that an object winds up "in the garbage collected zone" when code calls CFMakeCollectable. Conversely, "GC-unaware code" would not, I would think, call CFMakeCollectable (that seems like a very "GC-aware" thing to do, right?).

I suppose in a scenario where some code is using an object allocated by some other code, where that other code has called CFMakeCollectable, but the first code is "GC-unaware", that would be an exception to the statements made. But it doesn't seem like an important exception to me, because that first code shouldn't be assuming ownership or control over the object anyway (i.e. obviously it got the object from somewhere else, and it has no reason to believe that it holds the last retain on the object, even if that first code doesn't know anything about garbage-collection).

If I've somehow misconstrued what either of you wrote, I apologize. But as things stand now, I'm not convinced you're in contradiction with each other.

Pete_______________________________________________

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

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

Reply via email to