Re: Garbage collection in XCode 2.1, and Cocoa
Re: Garbage collection in XCode 2.1, and Cocoa
- Subject: Re: Garbage collection in XCode 2.1, and Cocoa
- From: Jonathon Mah <email@hidden>
- Date: Sat, 30 Jul 2005 00:51:01 +0930
On 2005-07-29, at 01:11, Markus Hitter wrote:
OK, thanks for the replies on the garbage collection end; its too
bad that it currently doesn't work, it would be nice to have.
What do you do with people who consider garbage collection as a
source of unexpected behaviour and a waste of cycles? Reference
counting is a snap if you know what you are doing.
I quite like refcounting, as implemented in Objective-C and Cocoa.
Once you know what you're doing it's simple to do, and you know
exactly when objects get allocated and deallocated (no wondering "is
this loop slow because the runtime decided to garbage collect in the
middle of it?"). However for some common cases, garbage collection
would offer an advantage:
1. Getter accessor methods: Do you 'return value;', or 'return
[[value retain] autorelease];'? In other words, should an object
return a value that will be valid even if the object is deallocated?
Or should the calling method retain values "just in case"? The
confusion can lead to unexpectedly deallocated objects, and/or a lot
of unnecessary retains and autoreleases.
2. Vague rules for retaining: Sometimes it's not clear whether one
object should retain another. This lead to the (in)famous "binding
through File's Owner" memory leak, amongst others.
I don't want to start a flame war about these two issues, but I'm
just saying that there are some definite advantages to garbage
collection. (Of course, there are disadvantages too.)
Jonathon Mah
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden