Re: GC pros and cons
Re: GC pros and cons
- Subject: Re: GC pros and cons
- From: Graham Cox <email@hidden>
- Date: Sat, 27 Jun 2009 13:11:31 +1000
On 27/06/2009, at 11:20 AM, WT wrote:
2) Stick to retain/release and have to maintain a potentially
extremely complicated object graph, with potentially large and
interlocking retain cycles?
In practice this isn't the bogeyman that people (particularly newbies)
tend to assume. I'd say my current app was reasonably large and
complicated, consisting of a fairly large drawing engine framework
(Drawkit) overlaid by an even larger controller/UI and customisation
layer which is currently twice the size of DrawKit and growing. We're
talking millions of lines of code spread across some 500+ classes with
a great deal of inter-object communication at many levels.
I use retain/release throughout, and I still prefer it.
Obviously the potential for retain cycles and other pitfalls is there,
but you can usually take care of these at a fairly detailed,
microscopic level. In other words, when a class is developed in
isolation, if you take care to be mindful of the ownership rules, you
can avoid these problems easily. Cycles occurring at a higher, macro-
level, caused by the way the objects interact with each other tends to
take care of itself. Your design dictates who owns what, and that
relationship is clear and doesn't vary. Code accordingly. If your
design is unclear, ill thought-out or non-existent, you'll get into
trouble. But you will anyway, regardless of the memory management
technology. In fact GC may even be harmful in helping a bad design
limp along when really it's the bad design that should be fixed.
Using GC may mean you can avoid even that small degree of necessary
care, but the ownership rules are straightforward, easily learned and
committed to mind, and are hardly arcane or arbitrary - they are
simple and logical. I'd really rather deal with that and the odd bug
where I forgot something than the performance hit I'm going to take
when GC kicks in. I know that this hit is small, but so is the effort
required to use retain/release, so it seems to me we are arguing about
small stuff here, not big stuff.
I don't really get why the memory management/ownership rules seem to
be so hard for so many people. But I accept that they are, to some. If
they are, maybe GC is a godsend to those folk, but for everyone else,
I just can't see the big deal.
--Graham
_______________________________________________
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