This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: status of gcj's boehm collector?


...System.gc()...
> In that case, how would a latency-sensitive application signal the GC
> that it is now "okay" to stop-the-world for a long time (ie perform a
> full heap scan)?
I looked it up in response to your message.  Sun's documentation states:
"When control returns from the method call, the Java Virtual Machine has
made a best effort to reclaim space from all discarded objects."  The one
line summary states "Runs the garbage collector".  Thus just having the VM
ignore it seems a bit dubious; calling it as a hint that this might be a
good time to run the collector is even more dubious; you really need to know
that there has been a significant amount of allocation since the last
collection, since it's likely the VM will unconditionally go ahead and
collect.  And I think there's usually no good way to know that.

Another problem is that this sort of opportunistic garbage collection should
really be abortable if you get an unexpected request for more work during
the GC.  The underlying collector supports that (except for the parallel
marker), but there is no standard Java interface for it.
> 
> I thought that was the whole point of System.gc() -- it might not
> actually cause a GC; it's just a hint to the GC that "now is a safe
> time to pause the application for a while". Sorta like Thread.yield().
> 
I think Thread.yield() can be used correctly.  (It probably isn't in many
cases.  It's too easy to use Thread.yield()s in a loop to wait for
something.)  I'm not sure how to use System.gc() correctly except perhaps
for measurement purposes.

Hans  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]