This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Controlling the garbage collector (GC) at RT?
- From: Martin Egholm Nielsen <martin at egholm-nielsen dot dk>
- To: java at gcc dot gnu dot org
- Date: Wed, 02 Feb 2005 12:22:56 +0100
- Subject: Controlling the garbage collector (GC) at RT?
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