Detailed explanation of ParallelGC logs

GC log related JVM parameters

There are 8 JVM parameters related to GC logs:

parameter name Parameter meaning
-XX:+PrintGC Output brief GC log
-verbose:gc Equivalent to -XX:+PrintGC
-XX:+PrintGCDetails Output detailed GC logs
-XX:+PrintGCTimeStamps Output the timestamp of GC (total time from JVM startup to current time)
-XX:+PrintGCDateStamps Output the timestamp of the GC (in the form of date, such as 2013-05-04T21:53:59.234+0800)
-XX:+PrintHeapAtGC Print heap information before and after GC
-XX:+PrintReferenceGC Print the number and duration of each reference in the young generation
-Xloggc:gc.log Output GC logs to the file gc.log

-XX:+PrintGC and -verbose:gc

Although it is said above that these two parameters are equivalent, -verbose:gc is a standard parameter, and -XX:+PrintGC is marked as deprecated after JDK 9, so it is recommended to use -verbose: gc instead of -XX:+PrintGC.

Using the -verbose:gc parameter will turn on abbreviated GC logging. You can see GC logs like this:

This parameter is no longer used frequently, so we will not explain it in detail.

[GC (Allocation Failure) [PSYoungGen: 1363219K->24905K(1368576K)] , 0.0187118 secs]

-XX:+PrintGCDetails

After using this parameter, detailed GC logs will be printed, and the content printed includes the content printed by the -verbose:gc parameter.

[GC (Allocation Failure) [PSYoungGen: 1363219K->24905K(1368576K)] 1983835K->646622K(2066944K), 0.0187118 secs] [Times: user=0.05 sys=0.00, real=0.02 secs]

We split the above log into:

  • GC represents the type of garbage collection. GC means that Minor GC has occurred.Full GCIndicates that a Full GC has occurred
  • Allocation Failure briefly describes why GC occurs. In the above example, it is because there is no suitable space in the young generation that the new object allocation fails and GC occurs.
  • [PSYoungGen: 1363219K->24905K(1368576K)] shows the garbage collector used, the change in young generation occupancy, and the size of the young generation. In this example, the usage of the young generation is reduced from 1363219KB to 24905KB.
  • 1983835K->646622K(2066944K) shows the change in the occupancy of the entire heap and the size of the entire heap
  • [Times: user=0.05 sys=0.00, real=0.02 secs] indicates the time consumed by this GC.
user 代表垃圾回收器消耗的 CPU 时间
sys 代表系统调用或等待系统事件消耗的时间
real 代表应用实际停止的时间,近似于 (user + sys) / 垃圾回收器使用的线程数

-XX:+PrintGCTimeStamps

This parameter does not affect the detail level of the log. After it is turned on, the number of milliseconds from the start of the JVM to the time when the log appears will appear in the log, such as 358952.455 in the example below.

358952.455: [GC (Allocation Failure) [PSYoungGen: 1363219K->24905K(1368576K)] 1983835K->646622K(2066944K), 0.0187118 secs] [Times: user=0.05 sys=0.00, real=0.02 secs]

-XX:+PrintGCDateStamps

This parameter does not affect the detail level of the log. After opening, the time and time zone when the log is printed will be added to the log header, such as 2020-11-06T05:58:40.250+0000 in the example below.

2020-11-06T05:58:40.250+0000: 358952.455: [GC (Allocation Failure) [PSYoungGen: 1363219K->24905K(1368576K)] 1983835K->646622K(2066944K), 0.0187118 secs] [Times: user=0.05 sys=0.00, real=0.02 secs]

Guess you like

Origin blog.csdn.net/cljdsc/article/details/132768973