首页 > 代码库 > JVM参数和jvm.log
JVM参数和jvm.log
参数说明:
-Xms 初始堆大小-Xmx 最大堆大小-Xmn 年轻代大小 eden + 2 survivor space-XX:SurvivorRatio=8 Eden区与Survivor区的大小比值-XX:PermSize 设置持久代(perm gen)初始值-XX:MaxPermSize 设置持久代最大值-Xss 每个线程的堆栈大小-XX:CMSInitiatingOccupancyFraction= 年老代使用空间比达到这个值时开始cms gc-XX:+PrintGCApplicationStoppedTime 打印垃圾回收期间程序暂停的时间-XX:+PrintGCApplicationConcurrentTime 打印每次垃圾回收前,程序未中断的执行时间-XX:+PrintHeapAtGC 打印GC前后的详细堆栈信息
测试配置:
-Xms1000m -Xmx1000m -Xmn400m -XX:PermSize=128m -XX:MaxPermSize=128m-Xss512k-XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:SurvivorRatio=8 -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/data/lxx.jvm-XX:CMSInitiatingOccupancyFraction=80
Young GC:
日志:
2015-01-15T16:04:24.237+0800: 1691.665: [GC 1691.665: [ParNew: 350110K->22406K(368640K), 0.0055010 secs] 430492K->105988K(983040K), 0.0055690 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
日志说明:
2015-01-15T16:04:24.237+0800: 1691.665: [ GC 1691.665: [ # (Young GC) 时间戳 ParNew: # ParNew(使用ParNew作为年轻代的垃圾回收期) 350110K->22406K(368640K), # 年轻代 回收前大小->回收后大小(年轻代容量) 0.0055010 secs # 回收时间 ] 430492K->105988K(983040K), # 堆 回收前大小->回收后大小(堆容量) 0.0055690 secs # 回收时间 ] [ Times: user=0.02 sys=0.00, real=0.01 secs # Young GC用户耗时, Young GC系统耗时, Young GC实际耗时 ] 内存容量 年轻代: 368640K(360M) = 400M / (8 + 1 + 1) * (8 + 1) (始终闲置着40M) 堆: 983040K(960M) = 1000M - 40M 内存变化: 年轻代: 368640K(360M) 350110K - 22406K = 327704K 堆: 983040K(960M) 430492K - 105988K = 324504K 327704K - 324504K = 3200K 被移动到了Old Gen
Full GC
日志:
2015-01-15T16:29:53.894+0800: 3221.322: [Full GC 3221.322: [CMS: 614343K->614234K(614400K), 0.4258390 secs] 982961K->973059K(983040K), [CMS Perm : 121449K->121449K(131072K)], 0.4259380 secs] [Times: user=0.43 sys=0.00, real=0.42 secs]
2015-01-15T16:28:49.218+0800: 3156.645: [Full GC (System) 3156.645: [CMS2015-01-15T16:28:49.377+0800: 3156.805: [CMS-concurrent-mark: 0.165/0.166 secs] [Times: user=0.19 sys=0.00, real=0.17 secs]
日志说明:
Full GC (System) # 显式调用System.gc产生的 2015-01-15T16:29:53.894+0800: 3221.322: [ Full GC 3221.322: [ # (Full GC) 时间戳 CMS: 614343K->614234K(614400K), # old区 回收前大小->回收后大小(old区容量) 0.4258390 secs # 回收时间 ] 982961K->973059K(983040K), [ # 堆 回收前大小->回收后大小(堆容量) CMS Perm : 121449K->121449K(131072K) # Perm区 回收前大小->回收后大小(Perm区容量) ], 0.4259380 secs # 回收时间 ] [ Times: user=0.43 sys=0.00, real=0.42 secs ] 内存容量 Old区: 614400K(600M) = 1000M - 400M = 960M - 360M 堆: 983040K(960M) 内存变化: Old区: 614400K(600M) 614343K - 614234K = 109K 堆: 983040K(960M) 982961K - 973059K = 9902K
ParNew (promotion failed)
发生在新生代晋升老年代时,老年代空间不够或连续空间不够却还没达到old区的触发值,引发Full Gc.
2015-01-15T16:26:07.003+0800: 2994.431: [GC 2994.431: [ParNew (promotion failed): 351815K->349784K(368640K), 0.0095780 secs]2994.441: [CMS2015-01-15T16:26:07.074+0800: 2994.502: [CMS-concurrent-mark: 1.043/1.166 secs] [Times: user=4.25 sys=0.03, real=1.16 secs]
concurrent mode failure
发生在CMS GC 运行过程中,老年代空间不足,引发MSC
2015-01-15T16:26:07.003+0800: 2994.431: [GC 2994.431: [ParNew (promotion failed): 351815K->349784K(368640K), 0.0095780 secs]2994.441: [CMS2015-01-15T16:26:07.074+0800: 2994.502: [CMS-concurrent-mark: 1.043/1.166 secs] [Times: user=4.25 sys=0.03, real=1.16 secs]
(concurrent mode failure): 614155K->614338K(614400K), 0.5011370 secs] 960545K->632140K(983040K), [CMS Perm : 121434K->121434K(131072K)], 0.5108440 secs] [Times: user=0.52 sys=0.00, real=0.51 secs]
[参考] http://hot66hot.iteye.com/blog/2075819
JVM参数和jvm.log