How can I calculate the maximum “maximum heap size” avalable for java application
- in Windows using
cmdcommands? - in Linux using
shcommands?
I want to set -Xmx value as large as possible.
I want to be sure that java will not complain that -Xmx value is too large.
From a linked answer to another question I learned the following values for 32-bit Java:
OS: Windows XP SP2, JVM: Sun 1.6.0_02, Max heap size: 1470 MB OS: Windows XP SP2, JVM: IBM 1.5, Max heap size: 1810 MB OS: Windows Server 2003 SE, JVM: IBM 1.5, Max heap size: 1850 MB OS: Linux 2.6, JVM: IBM 1.5, Max heap size: 2750 MB
How do I automatically detect which OS and which Java is installed?
OK, I can default to the minimum value – 1470 MB.
But how can I be sure that in newer versions of Java this value will not shrink?
The question also remains open for 64-bit Java.
Try to run java with 2 gigabytes or memory, decrease the amount, repeat until java runs.
Linux:
Windows: