RE: JavaMemoryModel: Another Java threading issue (finalization)

From: Boehm, Hans (hans_boehm@hp.com)
Date: Tue Apr 01 2003 - 18:53:22 EST


> From: Alexander Terekhov [mailto:TEREKHOV@de.ibm.com]
>
> David Holmes wrote:
> [...]
> > Hmmm. I suppose if we just said "an object is always reachable while
> > an invocation upon it is active" then the compiler folk would get
> > upset?
>
> OTOH, I think that any concessions that would allow to evaporate
> objects "faster" than good old reference counting would surely
> upset everyone and his dog... except compiler folk, probably. ;-)
>
If you're comparing to C++-smart_pointer-like reference counting, that already happens and must continue to do so, for at least 3 reasons:

1) A serious Java implementation can't leak garbage cycles.
2) You don't really want to require the compiler to keep all dead reference variables live until the end of the block in which they were declared. That increases register pressure and space use, sometimes substantially.
3) Finalization is not ordered in Java. (In my opinion this is a mistake, but that's a very controversial opinion, and it's definitely not likely to change.) If A points to B, B may be finalized before A.

Hans
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:43 EDT