在华为项目中,之前我用的是JDK默认的GC收集器,初始上线数据量不大时没有问题,后来修改为:-XX:+UseConcMarkSweepGC,当时把-Xmn这个新生代的内存设置去掉了,也没有在启动后查看其新生代内存大小,结果一天后就报错了,我的JVM 内存设置为:
-server -Xms4096m -Xmx16000m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC,
但是用jstat -heap pid 输出结果为:
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 16777216000 (16000.0MB)
NewSize = 697892864 (665.5625MB)
MaxNewSize = 697892864 (665.5625MB)
OldSize = 1395851264 (1331.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 268435456 (256.0MB)
MaxPermSize = 536870912 (512.0MB)
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
New Generation (Eden + 1 Survivor Space):
capacity = 628162560 (599.0625MB)
used = 347078104 (330.99947357177734MB)
free = 281084456 (268.06302642822266MB)
55.25291160300926% used
Eden Space:
capacity = 558432256 (532.5625MB)
used = 338771848 (323.07801055908203MB)
free = 219660408 (209.48448944091797MB)
60.664806583092506% used
From Space:
capacity = 69730304 (66.5MB)
used = 8306256 (7.9214630126953125MB)
free = 61424048 (58.57853698730469MB)
11.911974455180921% used
To Space:
capacity = 69730304 (66.5MB)
used = 0 (0.0MB)
free = 69730304 (66.5MB)
0.0% used
concurrent mark-sweep generation:
capacity = 7884152832 (7518.9140625MB)
used = 5756140000 (5489.482879638672MB)
free = 2128012832 (2029.4311828613281MB)
73.00898552647438% used
Perm Generation:
capacity = 268435456 (256.0MB)
used = 99056544 (94.46768188476562MB)
free = 169378912 (161.53231811523438MB)
36.90143823623657% used
其中new size这项明显跟NewRatio = 2的设置不相符,结过大量的测试发现,由于设置了-XX:+UseConcMarkSweepGC,不知什么原因使NewRatio = 2的默认设置不生效,所以在设置并发GC后,必须要设置:-Xmn这个新生代的设置。
之后设置完毕后,重启后new size的大小就正常了,经验啊。
系统环境:
Redhat 6.5 64位,jdk1.7_51 64位
硬件配置:8C 32G, 200G
原文地址:http://blog.csdn.net/aolaog/article/details/44151933