Controlling the garbage collector (GC) at RT?

Martin Egholm Nielsen martin@egholm-nielsen.dk
Tue Feb 8 18:45:00 GMT 2005


Hi,

>> And in relation to that thread, what is the effect of adjusting
>> GC_free_space_divisor? (Maybe I should take that back in the old thread)
> The GC sets up memory pools of different sized objects.  If you have the 
> divisor set too low in conjunction with a limited maximum heap size you 
> can run into a situation where there are many of these pools that have 
> some free space in them, but there is no memory left to expand the pool 
> of a pool for a given size object.  The result is an OutOfMemoryError 
> even though the total space taken up by reachable objects is 
> significantly smaller than the total available memory.
Auch... I certainly don't want that, no. And I do have the specific 
situation with only a limited maximum heap.

However, if I just got an OOM I would be able to "handle" it somehow. 
But unfortunately my Linux terminates my application in the attempt to 
grow the heap size beyond the physical possible.
(Do you recall our similar discussion 
http://gcc.gnu.org/ml/java/2004-11/msg00130.html :-)

So ofcourse setting the GC_free_space_divisor as both you and Hans 
suggest, would circumvent some/many of the OOM I could encouter.

But it would also be really nice if I could, somehow, control the 
heap-increase-size (factor). It seems to be 1.33 today:

heap_last_increase_size *= 1.33;
heap_size += heap_last_increase_size;

I would like to specify an initial "heap_last_increase_size", and then 
an increase-factor of 1.0.
That way, I wouldn't have to specify the "GC_..._HEAP_SIZE" that 
accurately (and possibly risk overshooting if too ambitious, and 
undershooting with several megs if too carefull)...

>> Am I the only one that think a GCJ interface for controlling the GC
>> would be neat?
> I think it would be an excellent idea.  I have code that does a heap 
> dump  that I would be good to put in the interface as well.  Given the 
> heap dump and a post processing program we generate things like the 
> number and type of each reachable object as well as the value of each 
> String.  Many cool things are possible.
With the correct tool yes :-)
But how do you control the divisor today? That must be through some 
JNI/CNI interface?! Can't this be the start of this new interface?

Thanks!

// Martin



More information about the Java mailing list