I'm running JDK 1.1.7v3 on an i386 running RedHat 5.2. The JDK has a nasty
habit of bailing out with an out of memory error before my machine has
actualy run out of memory (yes, I used the mx option, also I have 192m of
ram with 100m swap space). I put together the following test program which
demonstrates the problem (on my i386 anyways, it works just fine on my
Solaris Sparc).

public class memHog {

    public static void main(String args[]) {
        int outerDimension = 64;
        int innerX = 1024;
        int innerY = 1024;

        System.out.println("Allocating " + 1024*1024*64*4 + " bytes.");
        int bigAssArr[][][] = new int[outerDimension][][];
        for (int i=0; i<outerDimension; ++i) {
            bigAssArr[i] = new int[innerX][];
            for (int j=0; j<innerX; ++j) {
                bigAssArr[i][j] = new int[innerY];
                for (int k=0; k<innerY; ++k) {
                    bigAssArr[i][j][k] = k;
                }
            }
            System.out.println(1024*1024*i*4 + " bytes allocated...");
        }
        System.out.println("DONE!");
    }
}

a sample run:

$ java -mx200m memHog
Allocating 134217728 bytes.
0 bytes allocated...
4194304 bytes allocated...
8388608 bytes allocated...
12582912 bytes allocated...
16777216 bytes allocated...
20971520 bytes allocated...
25165824 bytes allocated...
Before GC.  Free=187032.  Total=33660920.

After GC.  Free=187032.  Total=33660920.

DONE!

The amount of memory used does not have an obvious correlation to the mx
value(at least not obvious to me)

any sugestions??

thanks,
-Ben Edelman


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to