John Summerfield writes:
> Someone mentioned offline (please, all, keep discussion ON the list) that
> it's possible to force garbage collection. My code has the necessary
> statements to do that (two versions that I found).
If (as someone else indicated) Sun's JVM uses a conservative garbage
collector, then even though one may force garbage collection, there's
no way to force the garbage collector to recognize that a particular
object is in fact garbage.
Another writer seemed worried about memory consumption, and while it's
true that conservative GCs are not as efficient at reclaiming space as
traditional closed-world GCs, they're fine for most applications.
The semantics of the runFinalizersOnExit() method, as described in the
Javadoc for java.lang.System, are sweet; but I've never gotten that
method to work either. Those semantics would be very difficult (or
impossible) to achieve with a conservative garbage collector.
There is a workaround, if you don't need to garbage collect the
objects that must be finalized: in the constructor, add the new object
to a Vector; when you're done with one run the finalizer yourself.
Best,
daniel dulitz
Valley Technologies Peak Performance Real-Time DSP
State College, PA