虚拟机参数总结

来源:互联网 发布:淘宝包邮退货邮费规则 编辑:程序博客网 时间:2024/06/05 22:48

-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
原创粉丝点击