在刘冬的文章“
Java虚拟机的最大内存是多少 ”一文中
今天分析了当前比较流行的几个不同公司不同版本JVM的最大内存,得出来的结果如下:
公司 JVM版本 最大内存(兆)client 最大内存(兆)server
SUN 1.5.x 1492 1520
SUN 1.5.5(Linux) 2634 2660
SUN 1.4.2 1564 1564
SUN 1.4.2(Linux) 1900 1260
IBM 1.4.2(Linux) 2047 N/A
BEA JRockit 1.5 (U3) 1909 1902
除非特别说明,否则JVM版本都运行在Windows操作系统下
附:如何获得JVM的最大可用内存
在命令行下用 java -XmxXXXXM -version 命令来进行测试,然后逐渐的增大XXXX的值,如果执行正常就表示指定的内存大小可用,否则会打印错误信息。
实际发现版本上有细微差别的JDK最大容许内存值都不尽相同,因此在实际的应用中还是要自己试验一下看到底内存能达到什么样的值。
通过这个表想说明的是,如果你的机器的内存太多的话,只能通过多运行几个实例来提供机器的利用率了,例如跑Tomcat,你可以多装几个Tomcat并做集群,依此类推。 我在新到的一台dell 2850服务器上做测试
1、使用sun jdk1.4.2_07,测试结果为
[root@localhost bin]# ./java -Xmx3710M -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
[root@localhost bin]# ./java -Xmx3700M -version
java version "1.4.2_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-b05)
Java HotSpot(TM) Client VM (build 1.4.2_07-b05, mixed mode) 2、使用sun jdk 1.5.6,测试结果为
[root@localhost bin]# ./java -Xmx3700M -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
[root@localhost bin]# ./java -Xmx3600M -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode) 服务器的配置情况
[root@localhost bin]# top
top - 14:32:23 up 5 days, 21:06, 3 users, load average: 0.00, 0.03, 0.00
Tasks: 114 total, 1 running, 113 sleeping, 0 stopped, 0 zombie
Cpu0 : 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si
Cpu1 : 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si
Cpu2 : 2.3% us, 0.0% sy, 0.0% ni, 97.7% id, 0.0% wa, 0.0% hi, 0.0% si
Cpu3 : 0.3% us, 0.0% sy, 0.0% ni, 99.7% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 4044816k total, 1810908k used, 2233908k free, 92088k buffers
Swap: 2555888k total, 0k used, 2555888k free, 1333328k cached
[root@localhost bin]# cat /proc/meminfo
MemTotal: 4044816 kB
MemFree: 2234092 kB
Buffers: 92088 kB
Cached: 1333328 kB
SwapCached: 0 kB
Active: 671408 kB
Inactive: 939560 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 4044816 kB
LowFree: 2234092 kB
SwapTotal: 2555888 kB
SwapFree: 2555888 kB
Dirty: 0 kB
Writeback: 0 kB
Mapped: 230684 kB
Slab: 148664 kB
Committed_AS: 642520 kB
PageTables: 6332 kB
VmallocTotal: 536870911 kB
VmallocUsed: 264596 kB
VmallocChunk: 536606195 kB
HugePages_Total: 0
HugePages_Free: 0
Hugepagesize: 2048 kB
[root@localhost bin]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 2992.789
cache size : 2048 KB
physical id : 0
siblings : 2
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl cid cx16 xtpr
bogomips : 5931.00
clflush size : 64
cache_alignment : 128
address sizes : 36 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 2992.789
cache size : 2048 KB
physical id : 3
siblings : 2
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl cid cx16 xtpr
bogomips : 5980.16
clflush size : 64
cache_alignment : 128
address sizes : 36 bits physical, 48 bits virtual
power management:
processor : 2
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 2992.789
cache size : 2048 KB
physical id : 0
siblings : 2
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl cid cx16 xtpr
bogomips : 5980.16
clflush size : 64
cache_alignment : 128
address sizes : 36 bits physical, 48 bits virtual
power management:
processor : 3
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 2992.789
cache size : 2048 KB
physical id : 3
siblings : 2
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl cid cx16 xtpr
bogomips : 5980.16
clflush size : 64
cache_alignment : 128
address sizes : 36 bits physical, 48 bits virtual
power management: