Controlling the garbage collector (GC) at RT?
Martin Egholm Nielsen
martin@egholm-nielsen.dk
Wed Feb 2 11:24:00 GMT 2005
Hi there,
Does GCJ somehow support controlling the GC at runtime?
That is, e.g. configure it for different behaviour:
1) Run as you usually do
2) Please do not not run unless it is really needed
3) Don't run at all (let application die if it must)
Point 2 is actually what I'm after, but I'm reconsidering (as I'm
writing) if it actually makes any sense.
This could be implemented in some semaphore (reference-counting)
acquire/release way:
// Seen in one thread:
try
{
GCController.pleaseDontDoItNow();
...
} // try
finally
{
GCController.goAheadIDontCareAnymore();
} // finally
Hence, when the "pleaseDont"-count reaches 0, the GC is free to run.
The reason for posing this "question", is that I have an application
with several (two) threads with some "critical" (looping) sections, in
which I would rather not have the GC taking over control.
Hence, I plan on having each thread signal when it is out of its
critical section, and "force" a GC when the threads reach a common
moment of pausing (which _will_ happen - there's only two critical
threads, and they are somewhat correlated in behaviour).
Is this a very bad idea?
BR,
Martin Egholm
More information about the Java
mailing list