[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]Garbage Collector

From: Rhys Weatherley
Subject: Re: [DotGNU]Garbage Collector
Date: Fri, 14 Jun 2002 22:08:05 +1000

Boris Kolar wrote:

> I'd like to point out that this strategy may cause
> the concept of object finalization useless. The same
> problem appears in java (see an excellent article at

I'll take your word for it.  I'm no expert on

> A better approach (at least in some cases) would be to
> (incrementally) garbage collect an object immediately after
> it's no longer reachable.

Perhaps.  Unfortunately, detecting when an object is
no longer reachable quickly reduces to the halting
problem in C# and Java.  If it were tractable, there
would be no need for the GC at all.

> Ideally, the programmer would have the ability to
> decide garbage collection strategy for each object
> (for example, by implementing interface
> IncrementallyCollectable, the object would be

We have to remain compatible with C#, which does not
currently have such a facility.

It does have the IDisposable interface and the "using"
construct, which allows some control over when a
resource (such as an OS handle) is cleaned up.  But
this only reclaims the resource - not the memory for
the object - GC is still required for that.

The following old but fairly descriptive article goes
into why it is so hard to have predictable finalization
in a system like this:

I'll post my "Two Doofuses" play in a separate message.
It's a humourous description of why Java and C# are
the way they are.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]