Jacks, gij and the GC

Ranjit Mathew rmathew@gmail.com
Thu Apr 22 10:28:00 GMT 2004


Hi,

    I tried to run the Jacks testsuite with the current
mainline and, as usually happens for me, I quickly ran
into problems - *on every run*, my machine (a P4 2.6GHz
with 1GB RAM and 517MB swap, running Red Hat
Enterprise Linux 3 AS) froze after some time. The
kernel is Red Hat's 2.4.21-9.EL release.

After a bit of digging around, I found out that GCJ
goes nuts on the Jacks test case
"15.9.4-runtime-creation-2", which for your reference
is simply:
-------------------------- 8< --------------------------
class List {
    int value;
    List next;
    static List head = new List(0);
    List(int n) { value = n; next = head; head = this; }
}
class T1594rc2 {
    public static void main(String[] args) {
        int id = 0, oldid = 0;
        try {
            for (;;) {
                ++id;
                new List(oldid = id);
            }
        } catch (OutOfMemoryError e) {
            List.head = null; // try to reclaim memory
            System.out.print(oldid==id);
        }
    }
}
-------------------------- 8< --------------------------

In a well-behaving JVM this should print out
"false" after some time.

With both the GCJ interpreter and the compiled code
generated by GCJ however, my machine simply freezes.

By a "freeze" I mean that it stops responding to
everything, except Alt+Fn (shifting virtual consoles)
and that it *eventually* responds to a Ctrl+C but
after a VERY LONG time!

So I tried to limit the heap size by using the
"-mx" option to gij - the test finishes successfully
and well in time, but I get the output:

  GC Warning: Out of Memory!  Returning NIL!
  false

The "GC Warning" is on stderr. The "false" is the
expected output.

Starting from "-mx=64m", I kept increasing the heap
limit and went all the way to "-mx=1024m", and the
test still finished in time. Then I tried "-mx=1512m"
and the behaviour reappeared - "top" shows that
almost all the physical memory and all of the swap
memory is used up and in the "stable state" (!!),
gij takes up 95.8% of the memory and "kscand" takes
up all of the %CPU!

~sigh~

Anyways, to cut a long story short, I have
these questions:

1. Doesn't anyone else see this behaviour on Linux?

2. Why should the GC print out the "GC Warning" if
   we are throwing an OutOfMemoryError anyway?

3. Will my Jacks tests be considered "legitimate" if
   I use "-mx=64m"?

4. Is there an option corresponding to "-mx" to limit
   the heap size for natively compiled executables?

Thanks,
Ranjit.

-- 
Ranjit Mathew          Email: rmathew AT gmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/



More information about the Java mailing list