如何获得JVM的最大可用内存
在命令行下用 java -XmxXXXXM -version命令来进行测试,然后逐渐的增大XXXX的值,如果执行正常就表示指定的内存大小可用,否则会打印错误信息
SUN的1.2.2、1.3.1、1.4.2、1.5.0、IBM1.4.2、BEA JRockit 1.4.2
F:\JDK\1.2.2\bin>java -Xmx700000255M-version
java version "1.2.2"
Classic VM (build JDK-1.2.2_017, native threads, symcjit)
F:\JDK\1.2.2\bin>java -Xmx700000256M-version
Bad max heap size: -Xmx700000256M
Could not create the Java virtual machine.
=====================================================================
F:\JDK\1.3.1\bin>java -version
java version "1.3.1_18"
Java(TM) 2 Runtime Environment, Standard Edition (build1.3.1_18-b01)
Java HotSpot(TM) Client VM (build 1.3.1_18-b01, mixed mode)
F:\JDK\1.3.1\bin>REM If present, the option toselect the VM must be first.
F:\JDK\1.3.1\bin>REM The default VM is-hotspot.
F:\JDK\1.3.1\bin>java -hotspot -Xmx1554M-version
java version "1.3.1_18"
Java(TM) 2 Runtime Environment, Standard Edition (build1.3.1_18-b01)
Java HotSpot(TM) Client VM (build 1.3.1_18-b01, mixed mode)
F:\JDK\1.3.1\bin>java -hotspot -Xmx1555M-version
Error occurred during initialization of VM
Could not reserve enough space for object heap
F:\JDK\1.3.1\bin>java -server -Xmx1522M-version
java version "1.3.1_18"
Java(TM) 2 Runtime Environment, Standard Edition (build1.3.1_18-b01)
Java HotSpot(TM) Server VM (build 1.3.1_18-b01, mixed mode)
F:\JDK\1.3.1\bin>java -server -Xmx1523M-version
Error occurred during initialization of VM
Could not reserve enough space for object heap
F:\JDK\1.3.1\bin>java -classic -Xmx2047M-version
java version "1.3.1_18"
Java(TM) 2 Runtime Environment, Standard Edition (build1.3.1_18-b01)
Classic VM (build 1.3.1_18-b01, native threads, nojit)
F:\JDK\1.3.1\bin>java -classic -Xmx2048M-version
Bad max heap size: -Xmx2048M
Could not create the Java virtual machine.
=====================================================================
F:\JDK\1.4.2\bin>java -version
java version "1.4.2_12"
Java(TM) 2 Runtime Environment, Standard Edition (build1.4.2_12-b03)
Java HotSpot(TM) Client VM (build 1.4.2_12-b03, mixed mode)
F:\JDK\1.4.2\bin>REM The default VM isclient.
F:\JDK\1.4.2\bin>java -client -Xmx1308M-version
java version "1.4.2_12"
Java(TM) 2 Runtime Environment, Standard Edition (build1.4.2_12-b03)
Java HotSpot(TM) Client VM (build 1.4.2_12-b03, mixed mode)
F:\JDK\1.4.2\bin>java -client -Xmx1309M-version
Error occurred during initialization of VM
Could not reserve enough space for object heap
F:\JDK\1.4.2\bin>java -server -Xmx1308M-version
java version "1.4.2_12"
Java(TM) 2 Runtime Environment, Standard Edition (build1.4.2_12-b03)
Java HotSpot(TM) Server VM (build 1.4.2_12-b03, mixed mode)
F:\JDK\1.4.2\bin>java -server -Xmx1309M-version
Error occurred during initialization of VM
Could not reserve enough space for object heap
F:\JDK\1.4.2\bin>REM -hotspot is a synonym forthe "client" VM [deprecated]
F:\JDK\1.4.2\bin>java -hotspot -Xmx1308M-version
java version "1.4.2_12"
Java(TM) 2 Runtime Environment, Standard Edition (build1.4.2