GC日志参数详解

一、输出GC简要信息

-verbose:gc 或-XX:+PrintGC

[GC (Allocation Failure)  7987K->5378K(19456K), 0.0133927 secs]

[GC (Allocation Failure)  13570K->11246K(19456K), 0.0220739 secs]

[Full GC (Ergonomics)  11246K->11188K(19456K), 0.2417921 secs]

[Full GC (Ergonomics)  18717K->16418K(19456K), 0.2618319 secs]

[Full GC (Allocation Failure)  16418K->16398K(19456K), 0.1658426 secs]

7987K->5378K(19456K), 0.0133927 secs含义:GC前已使用容量->GC后已使用容量(总容量),GC耗时,单位s

GC (Allocation Failure) :说明GC类型,括号中说明发生GC的原因。如这里说明发生了minor gc,原因是内存分配失败。

二、输出GC详细信息

-XX:+PrintGCDetails

[GC (Allocation Failure) [PSYoungGen: 7970K->1017K(9216K)] 7970K->5382K(19456K), 0.0165871 secs] [Times: user=0.05 sys=0.00, real=0.02 secs] 

[GC (Allocation Failure) --[PSYoungGen: 9209K->9209K(9216K)] 13574K->19444K(19456K), 0.0325471 secs] [Times: user=0.08 sys=0.00, real=0.03 secs] 

[Full GC (Ergonomics) [PSYoungGen: 9209K->0K(9216K)] [ParOldGen: 10234K->10180K(10240K)] 19444K->10180K(19456K), [Metaspace: 3150K->3150K(1056768K)], 0.2389364 secs] [Times: user=0.36 sys=0.00, real=0.24 secs]

[PSYoungGen: 7970K->1017K(9216K)] 含义:新生代:GC前已使用容量->GC后已使用容量(新生代总容量)

7970K->5382K(19456K)含义:整个java堆:GC前已使用容量->GC后已使用总容量(java堆总容量)

0.0165871 secs 含义:GC耗时,单位s

Heap

 PSYoungGen      total 9216K, used 8192K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)

  eden space 8192K, 100% used [0x00000000ff600000,0x00000000ffe00000,0x00000000ffe00000)

  from space 1024K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x00000000fff00000)

  to   space 1024K, 48% used [0x00000000fff00000,0x00000000fff7be10,0x0000000100000000)

 ParOldGen       total 10240K, used 7990K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)

  object space 10240K, 78% used [0x00000000fec00000,0x00000000ff3cd898,0x00000000ff600000)

 Metaspace       used 3182K, capacity 4600K, committed 4864K, reserved 1056768K

  class space    used 357K, capacity 424K, committed 512K, reserved 1048576K
PSYoungGen      total 9216K, used 8192K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)含义:

新生代总大小9216K,已使用8192K,内存申请起始地址,已申请到的终点位置,最多能申请到的位置

三、GC前后堆的详细信息

-XX:+PrintHeapAtGC

{Heap before GC invocations=1 (full 0):

 PSYoungGen      total 9216K, used 7969K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)

  eden space 8192K, 97% used [0x00000000ff600000,0x00000000ffdc86a8,0x00000000ffe00000)

  from space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)

  to   space 1024K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x00000000fff00000)

 ParOldGen       total 10240K, used 0K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)

  object space 10240K, 0% used [0x00000000fec00000,0x00000000fec00000,0x00000000ff600000)

 Metaspace       used 3150K, capacity 4600K, committed 4864K, reserved 1056768K

  class space    used 353K, capacity 424K, committed 512K, reserved 1048576K

[GC (Allocation Failure) [PSYoungGen: 7969K->1001K(9216K)] 7969K->5366K(19456K), 0.0150862 secs] [Times: user=0.03 sys=0.00, real=0.02 secs] 

Heap after GC invocations=1 (full 0):

 PSYoungGen      total 9216K, used 1001K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)

  eden space 8192K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffe00000)

  from space 1024K, 97% used [0x00000000ffe00000,0x00000000ffefa798,0x00000000fff00000)

  to   space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)

 ParOldGen       total 10240K, used 4364K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)

  object space 10240K, 42% used [0x00000000fec00000,0x00000000ff0432e0,0x00000000ff600000)

 Metaspace       used 3150K, capacity 4600K, committed 4864K, reserved 1056768K

  class space    used 353K, capacity 424K, committed 512K, reserved 1048576K

}

invocations=1:发生GC的总次数(Major GC, Full GC)

full 0:发生Full GC的总次数

四、OOM dump文件转储

-XX:+HeapDumpOnOutOfMemoryError :发生OutOfMemoryError时,转储堆快照

-XX:HeapDumpPath=E:\java\dump :指定dump文件路径,不指定则默认放到项目路径下

可使用Memory Analyzer分析dump文件,

Eclipse安装地址:http://download.eclipse.org/mat/1.6.1/update-site/

下载地址:http://www.eclipse.org/mat/downloads.php

五、其他GC参数

-XX:+PrintGCTimeStamps:GC发生的时间,自JVM启动以后以秒计量

-XX:+PrintGCApplicationStoppedTime:输出GC造成应用暂停的时间,如:

Total time for which application threads were stopped: 0.3797230 seconds, Stopping threads took: 0.0000215 seconds

-XX:+PrintGCDateStamps:GC发生的时间,格式如:

2017-03-21T20:50:40.130+0800

-Xloggc:/logs/gc.log 输出GC日志到文件

欢迎指出本文有误的地方,转载请注明原文出处https://my.oschina.net/7001/blog/870988

你可能感兴趣的:(java异常,java内存,深入理解虚拟机)