虚拟机参数总结

-XX:+PrintGC   最简单的一个GC跟踪参数,只要遇到GC,就会打印日志,如下:

[GC 614K->304K(58880K), 0.0025790 secs]

[Full GC 304K->217K(58880K), 0.0121570 secs]

 上例中总共进行了2次GC,第一次仅为新生代GC,第二次为Full GC同时回收了新生代/老年代和永久区。

由日志可以看出GC前,堆使用量为614K GC后堆使用量为217K,当前可用堆空间总和约为60M(58880K)

最后,显示的是本次GC所花费的时间

-XX:+PrintGCDetails  打印更加详细的GC信息,如下:

[GC [PSYoungGen: 614K->288K(17920K)] 614K->288K(58880K), 0.0040100 secs] [Times: user=0.00 sys=0.01, real=0.01 secs]
[Full GC [PSYoungGen: 288K->0K(17920K)] [ParOldGen: 0K->217K(40960K)] 288K->217K(58880K) [PSPermGen: 2442K->2441K(21504K)], 0.0156540 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]


Heap
 PSYoungGen      total 17920K, used 921K [0x00000000ec000000, 0x00000000ed400000, 0x0000000100000000)
  eden space 15360K, 6% used [0x00000000ec000000,0x00000000ec0e6740,0x00000000ecf00000)
  from space 2560K, 0% used [0x00000000ecf00000,0x00000000ecf00000,0x00000000ed180000)
  to   space 2560K, 0% used [0x00000000ed180000,0x00000000ed180000,0x00000000ed400000)
 ParOldGen       total 40960K, used 217K [0x00000000c4000000, 0x00000000c6800000, 0x00000000ec000000)
  object space 40960K, 0% used [0x00000000c4000000,0x00000000c4036760,0x00000000c6800000)
 PSPermGen       total 21504K, used 2450K [0x00000000bee00000, 0x00000000c0300000, 0x00000000c4000000)
  object space 21504K, 11% used [0x00000000bee00000,0x00000000bf064a80,0x00000000c0300000)


     有以上日志可以看出,经历了2次GC,第一次仅为新生代GC,会后的效果是从GC前的614K降到288K,当前可用堆空间约为59M(58880K)

第二次为 Full GC 同时回收了新生代,老年代和永久区。其他信息解读与 上面解读一样

     该参数还会是虚拟机在退出前打印堆的详细信息,详细信息描述了当前堆的各个区间的使用情况。如上输出所示,当前新生代(new generation)总大小为17920K,以使用921K ,紧跟其后的三个16进制数字表示新生代的下界,当前上界和上界,使用当前上界减去下界,就是当前虚拟机已经为程序分配的空间大小,如果当前上界等于下界,说明堆空间已经没有扩大的可能。

-XX:+PrintHeapAtGC 打印堆更详细的对信息,有如下示例:

{Heap before GC invocations=1 (full 0):
 PSYoungGen      total 17920K, used 614K [0x00000000ec000000, 0x00000000ed400000, 0x0000000100000000)
  eden space 15360K, 4% used [0x00000000ec000000,0x00000000ec099a18,0x00000000ecf00000)
  from space 2560K, 0% used [0x00000000ed180000,0x00000000ed180000,0x00000000ed400000)
  to   space 2560K, 0% used [0x00000000ecf00000,0x00000000ecf00000,0x00000000ed180000)
 ParOldGen       total 40960K, used 0K [0x00000000c4000000, 0x00000000c6800000, 0x00000000ec000000)
  object space 40960K, 0% used [0x00000000c4000000,0x00000000c4000000,0x00000000c6800000)
 PSPermGen       total 21504K, used 2442K [0x00000000bee00000, 0x00000000c0300000, 0x00000000c4000000)
  object space 21504K, 11% used [0x00000000bee00000,0x00000000bf062a20,0x00000000c0300000)
Heap after GC invocations=1 (full 0):
 PSYoungGen      total 17920K, used 320K [0x00000000ec000000, 0x00000000ed400000, 0x0000000100000000)
  eden space 15360K, 0% used [0x00000000ec000000,0x00000000ec000000,0x00000000ecf00000)
  from space 2560K, 12% used [0x00000000ecf00000,0x00000000ecf50000,0x00000000ed180000)
  to   space 2560K, 0% used [0x00000000ed180000,0x00000000ed180000,0x00000000ed400000)
 ParOldGen       total 40960K, used 0K [0x00000000c4000000, 0x00000000c6800000, 0x00000000ec000000)
  object space 40960K, 0% used [0x00000000c4000000,0x00000000c4000000,0x00000000c6800000)
 PSPermGen       total 21504K, used 2442K [0x00000000bee00000, 0x00000000c0300000, 0x00000000c4000000)
  object space 21504K, 11% used [0x00000000bee00000,0x00000000bf062a20,0x00000000c0300000)
}
{Heap before GC invocations=2 (full 1):
 PSYoungGen      total 17920K, used 320K [0x00000000ec000000, 0x00000000ed400000, 0x0000000100000000)
  eden space 15360K, 0% used [0x00000000ec000000,0x00000000ec000000,0x00000000ecf00000)
  from space 2560K, 12% used [0x00000000ecf00000,0x00000000ecf50000,0x00000000ed180000)
  to   space 2560K, 0% used [0x00000000ed180000,0x00000000ed180000,0x00000000ed400000)
 ParOldGen       total 40960K, used 0K [0x00000000c4000000, 0x00000000c6800000, 0x00000000ec000000)
  object space 40960K, 0% used [0x00000000c4000000,0x00000000c4000000,0x00000000c6800000)
 PSPermGen       total 21504K, used 2442K [0x00000000bee00000, 0x00000000c0300000, 0x00000000c4000000)
  object space 21504K, 11% used [0x00000000bee00000,0x00000000bf062a20,0x00000000c0300000)
Heap after GC invocations=2 (full 1):
 PSYoungGen      total 17920K, used 0K [0x00000000ec000000, 0x00000000ed400000, 0x0000000100000000)
  eden space 15360K, 0% used [0x00000000ec000000,0x00000000ec000000,0x00000000ecf00000)
  from space 2560K, 0% used [0x00000000ecf00000,0x00000000ecf00000,0x00000000ed180000)
  to   space 2560K, 0% used [0x00000000ed180000,0x00000000ed180000,0x00000000ed400000)
 ParOldGen       total 40960K, used 217K [0x00000000c4000000, 0x00000000c6800000, 0x00000000ec000000)
  object space 40960K, 0% used [0x00000000c4000000,0x00000000c4036760,0x00000000c6800000)
 PSPermGen       total 21504K, used 2441K [0x00000000bee00000, 0x00000000c0300000, 0x00000000c4000000)
  object space 21504K, 11% used [0x00000000bee00000,0x00000000bf0626c0,0x00000000c0300000)
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值