Thank you for your response after my rather uncivilised message.
> But there are occasional cases in which some non-memory resource needs to
> be reclaimed when a memory block X becomes unreachable, and there is no
> easy other way to determine when that is.
Is it not true that when you say this, you are assuming that (memory block X
becoming unreachable) coincides with ((some object that encapsulates the non-
memory resource) becoming (dead (i.e. no longer live)))? Because, and correct
me if I'm wrong, the basic rationale for finalizers is that an object
encapsulates a native resource, so that the native resource can only be used
through method invocations whose target is the object, and as a result, when
the object is no longer live, the native resource can be cleaned up. By an
object being live, I mean that the last method invocation whose target is the
object has not yet completed. (This, of course, being a dynamic and generally
The point of my previous message was that _in principle_ (and this is a
qualification I erroneously omitted in my previous message) there need not be
a correspondence between the concept of liveness of an object and the concept
of reachability of a memory block. Any such correspondence depends on the
implementation of the virtual machine. Many examples of reasons why such
correspondence can be absent have been presented on this mailing list.
The important thing about liveness of an object is that it makes sense at the
abstract Java semantics level.
As a virtual machine designer, one could choose to establish a correspondence
between liveness of an object and reachability of a memory block, although
this would exclude a number of desirable implementation techniques.
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:44 EDT