Re: JavaMemoryModel: Semantics of finalize

From: David F. Bacon (
Date: Wed Mar 22 2000 - 16:19:45 EST

the paper is not yet publicly available (sorry). however, i may be able to
clarify this point.

if you are talking about a stop-the-world collector, even a generational
collector, then what you say is true: between detecting that the object has no
outstanding references and running the finalizer there has to be heavyweight
global synchronization.

however, if you have a concurrent collector, things become ambiguous. i've
implemented a reference-counting concurrent collector. one thread produces
increment and decrement operations, another thread consumes them and discovers
garbage. right now, in order to make sure that the consumer sees an up-to-date
set of inc/dec operations, i use a global syncrhonization operation (PowerPC
sync instruction).

however, at some future time i might want to implement this with page-level or
cache-line level synchronizations so that only that portion of the memory
holding the inc/dec operations is communicated. in that scenario the consumer
might discover an object to be garbage (because it sees the dec operation)
before it sees all the updates to the data fields.

essentially, as the ISA of the target hardware more and more resembles a
distributed memory architecture, the JMM becomes less and less tenable, because
it is riddled with assumptions (despite its designers best intentions) that the
shared memory is coherent.

JavaMemoryModel mailing list -

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