Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
- Subject: Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
- From: David Duncan <email@hidden>
- Date: Wed, 7 Oct 2009 14:00:20 -0700
On Oct 7, 2009, at 1:47 PM, Gabriel Zachmann wrote:
I did that and there is one sentence that I don't understand at all:
"CFMakeCollectable calls CFRelease, but has two supplementary
features: [...]; second, it’s a no-op in a reference counted
environment."
Shouldn't that be "a no-op in a GC environment." ?
No. CFRetain & CFRelease continue to work the same regardless of GC.
That is, the reference count field still exists, but Obj-C objects in
GC start life with a 0 retain count and -retain/-release/-retainCount/-
autorelease are no-op'd. CF objects still start life with a retain
count of 1, and thus you need to release them in order for them to
participate in GC. Since you do not want to release them in a ref
counted environment, CFMakeCollectable (and NSMakeCollectable) need to
do nothing in ref-counted (or your objects would vanish) and CFRelease
(not -release) in a GC environment.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
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