The maximum memory that is supported by each version of the JDK in different operating systems is not the same, but can be tested in the following ways.
C:>JAVA-XMXXXXM (g)-version
where xxx is the maximum memory value, M (g) is the measurement unit of memory, if the command can correctly display the version of the JDK and other information, indicating that the current JDK support testing the maximum memory
Quantity, otherwise the memory of the test exceeds the maximum supported by the JDK.
For example: My system is win7 64-bit
Java code c:\users\thinkpad>java-xmx16g-version Java version "1.6.0_30" Java (TM) SE Runtime Environment (build 1. 6.0_30-B12) Java HotSpot (TM) 64-bit Server VM (build 20.5-b03, mixed mode) Java code c:\users\thinkpad>java-xmx16g -version java Version "1.6.0_30" Java (tm) SE Runtime Environment (build 1.6.0_30-b12) Java HotSpot (tm) 64-bit Serve R VM (build 20.5-b03, Mixed mode)
C:\users\thinkpad>java-xmx16g-version
java Version "1.6.0_30"
Java (TM) SE Runtime Environment (build 1.6.0 _30-B12)
Java HotSpot (TM) 64-bit Server VM (build 20.5-b03, Mixed mode)
When you can't support it, you'll get an error.
Java code c:\users\thinkpad>java-xmx16000g-version Error occurred during initialization of VM could not reserve Enough space
forObject heap could not create the Java virtual machine. Java code c:\users\thinkpad>java-xmx16000g-version Error occurred during initialization of VM could not reserve en Ough space for object heap the could not create the Java virtual machine.
C:\users\thinkpad>java-xmx16000g-version
Error occurred during initialization of VM
could not reserve Enough space for object heap the
could not create the Java virtual machine.
Generally on the 32-bit machine, the maximum is located between the 1.5g-2g, on the 64-bit machine should have no restrictions on the above, the test to write 16G can also be the normal version of the information
Reprinted from: Black Hair: http://heisetoufa.iteye.com/