Re: GC pros and cons
Re: GC pros and cons
- Subject: Re: GC pros and cons
- From: Michael Ash <email@hidden>
- Date: Fri, 26 Jun 2009 17:52:46 -0400
On Fri, Jun 26, 2009 at 2:31 PM, James Gregurich<email@hidden> wrote:
>
> If my resource is handed off to some external subsystem for release and I can't DETERMINE the order of the releases with respect to each other and other components of my code, then I would call that non-deterministic and undesirable.
If nondeterministic memory deallocation is a dealbreaker for you, then
Cocoa is not for you, pure and simple.
You cannot predict when your objects will be destroyed in Cocoa.
Garbage collection is irrelevant to this fact, and changes nothing
about it except the degree.
Even a simple alloc/init/release pair is not guaranteed to destroy the
object on the release. The init method could store a strong reference
away somewhere, or do a retain/autorelease combo, or pass a reference
off to another thread, and now you're screwed.
All GC does is make it happen more often. You *never* could rely on
object lifetimes. If your non-GC code relies on precisely controlling
object lifetimes, then you have a bug, and should fix it.
Mike
_______________________________________________
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