GCJ and Boehm GC "Incremental Collection"

Boehm, Hans hans.boehm@hp.com
Tue Dec 6 18:11:00 GMT 2005


You probably want to look at GC_should_collect() in alloc.c.  It's
pretty obvious how to transform that into a "nearly ready to collect"
function.

You might also want to look at GC_try_to_collect(), which is officially
exported and declared in gc.h.  That gives you a way of starting an
abortable collection, i.e. you can effectively back out if you decide
you have something more important to do after all.  However, if you back
out, you lose the effort you invested.  This does not require virtual
memory support.  The general impression seems to be that this kind of
thing is rarely useful, but your application might be an exception.

Hans

> -----Original Message-----
> From: Craig A. Vanderborgh [mailto:craigv@voxware.com] 
> Sent: Tuesday, December 06, 2005 9:36 AM
> To: java@gcc.gnu.org
> Cc: Boehm, Hans
> Subject: Re: GCJ and Boehm GC "Incremental Collection"
> 
> 
> Hello Again,
> 
> Another idea has occurred to us, one that could reduce our need for 
> "incremental GC" in the short run.
> 
> What we have been trying to do for several years now is to 
> use certain 
> memory heuristics to "anticipate" our application's need for GC, and 
> then to request a GC ourselves as soon as possible before the 
> collector 
> would decide to do a "world-stopped" collection on its own.  
> This could 
> allow us to perform GC at a "less disruptive" time, for example at a 
> time that would not pause audio prompt playback in our application.
> 
> The trouble is that our attempts to come up with a predictive 
> criterion 
> for when GC will happen have all failed quite spectacularly.  The 
> closest we've come is by using 
> Runtime.freeMemory()/Runtime.totalMemory() to compute a "% 
> Java memory 
> available" and use a comparison to some constant to decide whether we 
> should request GC.
> 
> Needless to say, this kind of thing does not really work.  So the 
> question is - How can we find out whether Boehm GC is 
> "thinking about" 
> doing a collection before it actually decides to do one?  I'm 
> going to 
> go read the Boehm code and see what I can figure out, but any 
> input from 
> Dr. Boehm and others how to achieve this in an appropriate 
> way would be 
> greatly appreciated.
> 
> Thanks in advance,
> craig vanderborgh
> voxware incorporated
> 



More information about the Java mailing list