tags:

views:

556

answers:

2

I'm currently using sun's java 1.6 on a SL4 cluster.

For some reason, the 1.6 JVM is starting up with an impossibly large heap, and cannot start:

java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

If I start it with e.g. -Xmx1800M, then it works OK. So, I'm wondering where the default heap size is set, and more importantly how to change it?

The machine has 8GB of physical memory, and I believe that sun's server JVM is supposed to start with a default of half the memory up to 512M, but this is clearly not the case, as it's trying to allocate over 1800M.

EDIT: I realise that it's possible to use _JAVA_OPTIONS, but this feels a bit clunky; I was expecting a properties file somewhere, but so far I've been unable to find it.

+1  A: 

There is no properties file for this. According to Garbage Collector Ergonomics:

initial heap size:

Larger of 1/64th of the machine's physical memory on the machine or some reasonable minimum. Before J2SE 5.0, the default initial heap size was a reasonable minimum, which varies by platform. You can override this default using the -Xms command-line option.

maximum heap size:

Smaller of 1/4th of the physical memory or 1GB. Before J2SE 5.0, the default maximum heap size was 64MB. You can override this default using the -Xmx command-line option.


Note: The boundaries and fractions given for the heap size are correct for J2SE 5.0. They are likely to be different in subsequent releases as computers get more powerful.

Given you have 8GB of RAM, default maximum heap size should be 1GB assuming you're using Java 6.

cletus
OK, great. But that seems not to be the case, and I can't even find out what the default is, as it won't start with the default. Any idea why it isn't being set to 1GB, and what could be done? Is it fair to say that this is a bug in the JVM we have?
mo-seph
+1  A: 

There's no standard properties file. The (Sun) JVM has the default values hardcoded in it.

Brian Agnew
Hi Brian: Does this mean you can only change the heap size at run time? To be more precise, if I change the default and restart JVM, would the heap size restore to the "default values hardcoded"?
Michael Z