Garbage collection vs. reference counting in .NET
started 8/20/2001; 8:44:04 AM - last post 8/28/2001; 4:50:31 PM
|
|
Dejan Jelovic - Garbage collection vs. reference counting in .NET
8/20/2001; 8:44:04 AM (reads: 1976, responses: 3)
|
|
Garbage collection vs. reference counting in .NET |
One of the gripes I have about garbage collection is that it is, unlike reference counting, non-deterministic and thus unusable for managing resources other than memory. As a result managing resources is much easier in C++ than in, say, Java.
A while ago there was a heated discussion on one of the Develop Mentor mailing lists about the above problem. It culminated with a message in which Brian Harry, one of the Product Managers on the .NET team, explained why they decided to go with a tracing collector and not reference counting after all. A very interesting read.
Posted to implementation by Dejan Jelovic on 8/20/01; 8:49:15 AM
|
|
|
|
graydon hoare - Re: Garbage collection vs. reference counting in .NET
8/23/2001; 9:17:21 PM (reads: 825, responses: 0)
|
|
using the word "deterministic" here is misleading. ref counting is more "time-deterministic", when the zero-referencing thread is responsible for executing finalization code (note: not all languages put this responsibility on the zero-referencing thread), but it is markedly less "deterministic" about ensuring that the finalizer ever actually gets run; a cyclic graph will never be finalized in a pure ref counting environment.
in any event, as the article alludes to, reference counting is not entirely favourable for other reasons: you waste a lot of memory and cycles managing the counts and mutexes, when only one reference relationship is actually of any interest: unreachability.
gc is a well-studied area, not in the sense of hand-waving and postulation but in the sense of hard empirical studies and analysis. it's not a simple problem. there are many interesting implementations and a lot of good literature on the subject, including some surprising results
|
|
Ehud Lamm - Re: Garbage collection vs. reference counting in .NET
8/24/2001; 11:34:17 PM (reads: 851, responses: 0)
|
|
gc is a well-studied area, not in the sense of hand-waving and postulation but in the sense of hard empirical studies and analysis.
If this is meant as criticism of the content of the original link, I'd be happy if you could elaborate.
|
|
graydon hoare - Re: Garbage collection vs. reference counting in .NET
8/28/2001; 4:50:31 PM (reads: 813, responses: 0)
|
|
the only criticism I meant was that gc systems don't tend to yield to anecdotal analysis, nor "either/or" decisions based on single factors. gc systems vary along too many axes to make the decision simple; you need to collect data on the specific system you're building a gc for, and make practical tradeoffs against the design of your allocator, concurrency mechanism, operating system, language feature set, storage representation, etc. there isn't a single "right way" to do it.
|
|
|
|