《深入理解Java虚拟机》 垃圾收集器

———— JDK 1.8
words: 14.6k    views:    time: 71min
GC


垃圾收集器即对垃圾收集算法的实现,虚拟机规范并没有对垃圾收集器的实现做任何规定,因此不同的厂商可以自行实现。虽然可以将各个收集器放在一起进行比较,但并不能挑选出一款最好或者万能的收集器出来,只能在具体场景下选择最合适的收集器。

下图展示了7种作用于不同分代的经典收集器,图中的连线表示两个收集器可以搭配起来使用。这里说的经典是相对后面几款仍处于实验状态,但执行效果上有革命性改进的高性能低延迟收集器而言的。

1. 垃圾收集器

1.1. Serial 收集器

Serial是最基础,历史最久的收集器,曾经是JDK 1.3.1之前HotSpot虚拟机新生代收集器的唯一选择。其是一个单线程工作的收集器,并且它在进行垃圾收集时,必须暂停其他所有工作线程,直到它收集结束,也就是“Stop The World”。从JDK 1.3开始,一直到最新的JDK 13,HotSpot虚拟机团队为消除或者降低用户线程因垃圾收集而导致停顿所做的努力一直在持续,但仍然无法彻底消除。

.Serial/Serial Old 收集器过程示意图:

Serial收集器并不是老而无用,迄今为止,它依然是HotSpot虚拟机在客户端模式下新生代的默认收集器。其优点是简单而高效,对于内存受限的环境,它是所有收集器里额外内存消耗最小的。对于处理器数较少的环境,Serial没有线程交互的开销,专心做垃圾收集自然可以获得最高的单线程收集效率。

在桌面应用以及部分微服务应用中,分配给虚拟机管理的内存一般不会特别大,垃圾收集的停顿时间基本可以控制在几十毫秒左右,只要不是频繁发生收集,通常都可以接受。因此,Serial对运行在客户端模式下的虚拟机来说仍然是一个不错的选择。

1.2. ParNew 收集器

ParNew收集器实际上就是Serial的多线程并行版本,其行为以及相关的控制参数,包括对象分配规则、回收策略等都与Serial完全一致,因此它们在实现上也共用了相当多的代码。这里解释下并行与并发在垃圾收集器中的语义:

  • 并行:描述的是多条垃圾收集器线程之间的关系,即同一时间存在多条垃圾收集线程在协同工作;
  • 并发:描述的是垃圾收集器线程与用户线程之间的关系,即同一时间存在垃圾收集线程与用户线程同时工作;

.ParNew/Serial Old 收集器过程示意图:

ParNew一般是运行在服务端模式下HotSpot虚拟机的默认新生代收集器,尤其在JDK 1.7之前,它是除Serial之外,唯一能与CMS配合使用的收集器,因此,在使用-XX:+UseConcMarkSweepGC激活CMS收集器后,ParNew将是默认的新生代收集器,当然,也可以使用-XX:+/-UseParNewGC来指定或者禁用。

可以说是 CMS 的出现巩固了 ParNew 的地位,但随着更先进的 G1 收集器出现,其作为 CMS 的继承者或替代者登场,并且是一个面向全堆的收集器,因此不再需要其他新生代收集器配合。所以,从JDK 9开始,官方希望G1能完全替代服务端模式下默认的ParNew + CMS组合,并直接取消了对ParNew + Serial Old,以及Serial + CMS这两组收集器组合的支持,另外,还取消了参数-XX:+UseParNewGC,这意味着ParNew只能与CMS一起使用,或者说将ParNew合入了CMS。

1.3. Parallel Scavenge 收集器

Parallel Scavenge也是一款新生代收集器,同样基于标记-复制算法实现,并能够多线程并行收集。其与ParNew非常相似,只是关注点不同,它的目标是达到一个可控制的吞吐量,即用户代码执行时间所占的比率。

GCTimeRatio可以设置一个0到100之间的整数,用来控制垃圾收集时间所占的比率。默认:99,表示1/(1+99),即允许垃圾收集器占用1%的时间

MaxGCPauseMillis允许设置一个大于0的毫秒数,收集器会尽力但不保证让垃圾回收的时间不超时设定值。但是缩短垃圾收集停顿时间是以牺牲吞吐量和新生代空间为代价的,比如系统将新生代调小一点,
那么收集肯定会更快,但是也会更频繁,停顿时间在下降,但是吞吐量也降下来了。

1.4. Serial Old 收集器

Serial Old是Serial的老年代版本,同样是一个单线程收集器,也是使用标记-整理算法。

.Serial/Serial Old 收集器过程示意图:

该收集器的意义主要供客户端模式下的HotSpot使用,如果在服务端模式下则有两种用途,一种是在JDK 5之前的版本中配合Parallel Scavenge使用,另一种则是作为CMS收集器发生Concurrent Mode Failure时的后背方案。

1.5. Parallel Old 收集器

Parallel Old是Parallel Scavenge的老年代版本,支持多线程并发收集,也是基于标记-整理算法实现。

.Parallel Scavenge/Parallel Old 收集器过程示意图:

该收集器主要是为了与Parallel Scavenge配合使用,以达到吞吐量优先的目标。在注重吞吐量或者处理器资源较为稀缺的场景下,可以优先考虑该收集器组合。

1.6. CMS 收集器

CMS是一款追求最短停顿时间为目标的收集器,有的地方也称为并发低停顿收集器,试用于一些较为关在服务响应速度的场景中。其也是基于标记-清楚算法实现的,但是过程更复杂一些,具体有下面4个阶段:

  • 初始标记[CMS initial mark]:仅仅只是标记一下GC Roots能直接关联到的对象,速度很快,但需要Stop The World;

  • 并发标记[CMS concurrent mark]:即从GC Roots的直接关联对象开始遍历整个对象图,耗时较长但不需要停顿用户线程;

  • 重新标记[CMS remark]:修正并发标记期间,因为用户线程运作而导致变化的标记记录,耗时比初始标记稍长一些,但远小于并发标记阶段,不过也需要Stop The World;

  • 并发清除[CMS concurrent sweep]:清除标记阶段已判断为死亡的对象,由于不需要移动存活对象,因此该过程也可以与用户线程并发进行;

由于整个过程中,耗时最长的并发标记与并发清除阶段,都可以与用户线程并发进行,所有总体上可以认为CMS收集器的回收过程是与用户线程一起并发执行的。

.CMS 收集器过程示意图:

但CMS收集器也有缺点,其并发阶段虽然不会导致用户线程停顿,但由于收集线程占用了处理器资源,同样会导致应用程序变慢,从而降低总吞吐量。对于这个问题,CMS默认启动(处理器核数 + 3)/4个回收线程,这样当核数大于4时,收集器只占用不超过25%的处理器资源。

另外,由于CMS收集器在并发标记和并发清除阶段与用户线程并发执行,将会有新的垃圾不断产生,但这一部分垃圾对象是出现在标记过程结束之后,所有CMS无法处理掉它们,只能等下一次收集时再处理。对于这部分垃圾,就称为浮动垃圾

同样由于垃圾收集阶段用户线程还在执行,因此需要预留足够的空间给用户线程,而不能像之前的收集器一样等到老年代几乎填满再进行回收。如果预留空间过小导致程序无法分配新对象,那么会引起并发失败Concurrent Mode Failures,这时JVM不得不启用后备方案,即冻结用户线程,然后临时启用Serial Old收集器来重新进行老年代的收集,这样停顿时间就长了。但是,如果预留空间过大,则又可能会导致CMS收集操作触发的太过频繁。 因此,CMSInitiatingOccupancyFraction的值需要考虑实际情况,设置得太高可能导致大量的并发失败,而太低则可能导致收集动作频繁。其在JDK 5中,默认为68%,到了JDK 6之后改成了默认92%。

而且,由于CMS是基于标记-清除算法实现,这意味着收集之后会存在很多空间碎片。如果空间碎片过多,将会给大对象分配带来很大麻烦
往往会出现老年代还有很多剩余空间,但无法找到足够大的连续空间来为当前对象分配,而不得不提前触发一次Full GC。

对于这个问题,CMS提供了参数UseCMSCompactAtFullCollection(JDK 9中已经废弃),用于当CMS不得不进行Full GC时开启内存碎片的整理过程,由于这个过程必须移动存活对象,因此必须冻结用户线程,这样虽然解决了空间碎片问题,但停顿时间也更长了。另外,还提供了参数CMSFullGCsBeforeCompaction(JDK 9中也已经废弃)用于告诉CMS在执行指定次数Full GC之后,在下一次进入Full GC之前先进行碎片整理。

1.7. G1 收集器

G1(Garbage First)收集器是一款主要面向服务端应用的垃圾收集器,它开创了收集器面向局部收集的设计思路基于Region的内存布局形式。其最早在JDK 7中立项,但直到JDK 8 Update 40,完成了并发的类卸载支持之后,即补全了其计划功能的最后一块拼图,才被Oracle官方称为:全功能垃圾收集器。

JDK 9发布之后,官方宣布G1取代Parallel Scavenge + Serial Old,称为服务端模式下的默认收集器。另外,在规划JDK 10的功能目标时,HotSpot提出了统一垃圾收集器接口,希望将内存回收的行为与实现进行分离。由于历史原因,CMS及之前的收集器在实现中与HotSpot的内存管理、执行、编译监控等功能有着千丝万缕的关系,因此并不符合职责分离的设计原则,所以希望能基于统一的接口进行重构,这也算是为CMS退出历史舞台做最后的铺路了。

G1基于Region的内存布局形式是它能够实现停顿时间可控的关键。虽然G1也是基于分代收集理论设计的,但它不再坚持以固定大小或固定数量的分代区域进行划分,而是把连续的Java堆划分成若干大小相等的独立区域(Region),每个Region可以根据需要,选择扮演新生代的Eden,或者Survivor,以及老年代,收集器能够对扮演不同角色的Region采用不同的策略去处理,这样无论对象是新建的还是存活的,都能得到很好的处理。

虽然G1保留了新生代和老年代的概念,但它们不再是固定的了,而是一系列区域(不需要连续)的动态集合。G1会将Region作为单词回收的最小单元,具体实现时会跟踪各个Region中垃圾堆积的大小,以分析它们的回收价值,然后维护一个优先级列表,并在收集时优先处理回收价值高的Region,这也就是Garbage First名称的由来。

如果不去计算用户线程执行过程中的动作,G1收集器的运作过程大致可以分为4个步骤:

  • 初始标记[Initial Marking]:标记一下GC Roots能直接关联到的对象,并修改TAMS指针的值,让下一阶段用户线程并发运行时,能正确地在可用的Region中分配新对象。速度很快,但需要Stop The World;

  • 并发标记[Concurrent Marking]:从GC Roots开始对堆中对象进行可达性分析,递归扫描整个堆中的对象图,找出要回收的对象。耗时较长,但可以与用户线程并发执行。在扫描完之后,还要重新处理SATB记录下的在并发时有引用变动的对象;

  • 最终标记[Final Marking]:对用户线程做一个短暂的暂停,用于处理并发阶段结束后,仍然遗留下来的少量SATB记录。

  • 筛选回收[Live Data Counting and Evacuation];负责更新Region的统计数据,对各个Region的回收价值和成本进行排序,根据用户期望的停顿时间(可通过MaxGCPauseMillis指定,默认200ms)来制定回收计划,可以自由选择任意多个Region组成回收集,然后将存活对象复制到空的Region中,再清理掉被回收的Region空间。由于过程中涉及到对象移动,所以也需要暂停用户线程,但这里是由多个收集器线程并行完成的。

.G1 收集器过程示意图:

从Oracle官方透露,原本回收阶段也想过设计成与用户线程并发执行的,但这件事做起来比较复杂,而且考虑到G1只是回收一部分Region,停顿时间是用户可控的,所以并不那么迫切要实现。另外,G1的设计目标并不是仅仅面向低延迟,停顿用户线程能够最大幅度提高垃圾收集的效率,这样就保证了吞吐量。

对于停顿时间期望值MaxGCPauseMillis的设置需要符合实际,毕竟G1需要冻结用户线程来负责移动对象,这个时间再怎么低也需要有个限度。一般来说,回收阶段占用几十到一百甚至两百毫秒都很正常,但如果设置得非常低,比如20ms,那么很可能出现由于期望停顿时间太短,导致每次选出来的回收集只占堆内存很小的一部分,然后收集器收集的速度逐渐跟不上分配器分配的速度,导致垃圾慢慢堆积。很可能一开始收集器还能从空闲的堆中获得一些喘息的时间,但应用运行时间一长就不行了,最终导致堆被占满而引发Full GC,反而性能降低。

从G1开始,垃圾收集器都不约而同的将设计目标改为追求能够应付应用的内存分配速率,而不再追求一次把整个Java堆都清理干净。这样,应用在分配,同时收集器在收集,只要收集的速度能跟得上对象分配的速度,那一切就能运作得很完美,这种新的收集器设计思路从工程上看就是从G1开始兴起的,比如JDK 9之后退出的ZGC收集器和Shenandoah收集器,所以说G1是收集器技术发展的一个里程碑。

2. GC 日志

2.1. GC日志参数

下面列举了一些常用的GC日志打印参数

JDK 1.8日志参数:
-verbose:gc 打印GC日志
-XX:+PrintGC 效果与-verbose:gc一样,区别在于是否是稳定版本
-XX:+PrintGCDetails 打印GC详细日志,并在进程退出前打印堆的详情信息
-XX:+PrintTenuringDistribution 打印GC后新生代各个年龄对象的大小
-XX:+PrintHeapAtGC 每次GC前后打印堆信息
-XX:+PrintReferenceGC 跟踪软引用、弱引用、虚引用和Finallize队列
-XX:+PrintGCTimeStamps 打印GC发生的时间
-XX:+PrintGCApplicationConcurrentTime 打印进程的执行时间
-XX:+PrintGCApplicationStoppedTime 打印进程由于GC而产生的停顿时间
-Xloggc 指定GC日志文件,比如:-Xloggc:log/gc.log

2.2. GC日志格式

具体每种收集器的日志形式都由其自身的实现所决定,不过为了方便使用者阅读,也维持了一定的共性,例如UseParallelGC

1
2
3
4
5
6
7
8
9
0.532: [GC (Allocation Failure) 
[PSYoungGen: 33280K->5108K(38400K)] 33280K->5652K(125952K), 0.0072743 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]

0.929: [Full GC (Metadata GC Threshold)
[PSYoungGen: 5110K->0K(38400K)]
[ParOldGen: 7075K->9066K(87552K)] 12185K->9066K(125952K),
[Metaspace: 20831K->20829K(1067008K)], 0.0239430 secs]
[Times: user=0.13 sys=0.00, real=0.02 secs]
  • 最前面的数字0.5320.929,表示GC发生的时间,是Java虚拟机自启动以来经过的秒数;

  • 开头的[GC[Full GC,表示垃圾收集的停顿类型,如果有[Full,说明发生了Stop-The-World;

  • 后面的[PSYoungGen[ParOldGen[Metaspace,表示GC发生的区域,具体名称与使用的GC收集器相关;

  • 方括号内,比如33280K->5108K(38400K),表示GC前使用量 -> GC后使用量(该区域内存总量)

  • 方括号外,比如33280K->5652K(125952K),表示GC前Java堆使用量 -> GC后Java堆使容量(Java堆总容量)

  • 最后的时间,比如0.0072743 secs,表示该区域GC所用的时间,单位秒。

  • 最后面的Times中,分别表示用户消耗CPU时间、内核消耗CPU时间、操作从开始到结束所经过的墙钟时间。

墙钟时间与CPU时间的区别是它包括各种非运算的其它耗时,如等待磁盘I/O、等待线程阻塞,而CPU时间则不包括这些。另外,当系统有多CPU或者多核的话,多线程操作会叠加这些CPU时间,所以当看到usersys时间超过real也是正常的。

2.3. GC触发原因

导致GC的原因有很多,JVM中对各种原因进行了一个枚举

GCCause
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "precompiled.hpp"
#include "gc/shared/gcCause.hpp"

const char* GCCause::to_string(GCCause::Cause cause) {
switch (cause) {
case _java_lang_system_gc: // 显式调用System.gc(),或者在visualvm等软件上通过JMX监控时点击触发
return "System.gc()";

case _full_gc_alot:
return "FullGCAlot";

case _scavenge_alot:
return "ScavengeAlot";

case _allocation_profiler:
return "Allocation Profiler";

case _jvmti_force_gc: // JVM提供的native编程接口, JVMTI是实现Java调试器,以及其它运行时分析工具的基础
return "JvmtiEnv ForceGarbageCollection";

// 当通过JNI方式操作数组或者字符串时,为了避免GC过程移动数组或字符串的内存地址,
// JVM实现了一个GC_locker这样的东西,用于表示有线程在JNI临界区内,阻止其他线程进行GC操作。
// 然后当最后一个位于JNI临界区内的线程退出临界区时,将发起一次CGCause为_gc_locker的GC。
case _gc_locker:
return "GCLocker Initiated GC";

// jmap -hisot:live命令时会触发,或者在设置了PrintClassHistogramBeforeFullGC,
// 或PrintClassHistogramAfterFullGC时,会在fullgc之前或者之后触发一次GCCause=_heap_inspection的GC
case _heap_inspection:
return "Heap Inspection Initiated GC";

case _heap_dump: // dump堆时触发
return "Heap Dump Initiated GC";

// 很少见,用于whitebox测试,
// 见https://wiki.openjdk.java.net/display/HotSpot/The+WhiteBox+testing+API
case _wb_young_gc:
return "WhiteBox Initiated Young GC";

case _wb_conc_mark:
return "WhiteBox Initiated Concurrent Mark";

case _wb_full_gc:
return "WhiteBox Initiated Full GC";

case _update_allocation_context_stats_inc:
case _update_allocation_context_stats_full:
return "Update Allocation Context Stats";

case _no_gc: // CMS并发标记的阶段
return "No GC";

case _allocation_failure: // 常见的内存分配失败时触发的GC。比如在new对象时
return "Allocation Failure";

case _tenured_generation_full:
return "Tenured Generation Full";

case _metadata_GC_threshold: // metaspace区域分配失败时触发的GC,该GC会接着引起Full GC
return "Metadata GC Threshold";

case _metadata_GC_clear_soft_refs:
return "Metadata GC Clear Soft References";

case _cms_generation_full:
return "CMS Generation Full";

case _cms_initial_mark: // 设置CMS回收器时,后台初始标记阶段
return "CMS Initial Mark";

case _cms_final_remark: // 设置CMS回收器时,最终标记阶段
return "CMS Final Remark";

case _cms_concurrent_mark: // 设置CMS回收器时,并发回收阶段
return "CMS Concurrent Mark";

case _old_generation_expanded_on_last_scavenge:
return "Old Generation Expanded On Last Scavenge";

case _old_generation_too_full_to_scavenge:
return "Old Generation Too Full To Scavenge";

// Parallel Scavenge + Serial Old组合时,
// 如果老生代的剩余空间少于下一次收集所需的剩余空间,那么现在就做一个Full GC
// JDK8默认开启AdaptiveSizePolicy,会根据GC情况动态调整堆以及各个区大小
// 其实就是JVM估算下次分配可能会发生无法分配的问题,于是提前触发一次Full GC
case _adaptive_size_policy:
return "Ergonomics";

case _g1_inc_collection_pause: // 设置G1回收器时,分配失败触发的GC
return "G1 Evacuation Pause";

case _g1_humongous_allocation: // 分配超大对象失败时触发的GC
return "G1 Humongous Allocation";

case _dcmd_gc_run:
return "Diagnostic Command";

case _last_gc_cause:
return "ILLEGAL VALUE - last gc cause - ILLEGAL VALUE";

default:
return "unknown GCCause";
}
ShouldNotReachHere();
}

常见的导致GC的原因就是在new对象时,内存分配失败引起的,即Allocation Failure。首先进行Minor GC,对Eden区进行回收,然后将存活对象向Survivor区和老年代转移,如果发现老年代也无法分配了,那么会触发Full GC。比如下面这样

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{Heap before GC invocations=40 (full 2):
PSYoungGen total 13824K, used 13804K [0x00000000feb00000, 0x0000000100000000, 0x0000000100000000)
eden space 7168K, 100% used [0x00000000feb00000,0x00000000ff200000,0x00000000ff200000)
from space 6656K, 99% used [0x00000000ff980000,0x00000000ffffb010,0x0000000100000000)
to space 7168K, 0% used [0x00000000ff200000,0x00000000ff200000,0x00000000ff900000)
ParOldGen total 44032K, used 42330K [0x00000000fc000000, 0x00000000feb00000, 0x00000000feb00000)
object space 44032K, 96% used [0x00000000fc000000,0x00000000fe956bb8,0x00000000feb00000)
Metaspace used 39952K, capacity 41822K, committed 41984K, reserved 1085440K
class space used 5188K, capacity 5521K, committed 5632K, reserved 1048576K
32.411: [Full GC (Ergonomics) [PSYoungGen: 13804K->3933K(13824K)]
[ParOldGen: 42330K->43783K(44032K)] 56134K->47717K(57856K),
[Metaspace: 39952K->39918K(1085440K)], 0.4413646 secs] [Times: user=0.84 sys=0.03, real=0.44 secs]
Heap after GC invocations=40 (full 2):
PSYoungGen total 13824K, used 3933K [0x00000000feb00000, 0x0000000100000000, 0x0000000100000000)
eden space 7168K, 54% used [0x00000000feb00000,0x00000000feed7740,0x00000000ff200000)
from space 6656K, 0% used [0x00000000ff980000,0x00000000ff980000,0x0000000100000000)
to space 7168K, 0% used [0x00000000ff200000,0x00000000ff200000,0x00000000ff900000)
ParOldGen total 44032K, used 43783K [0x00000000fc000000, 0x00000000feb00000, 0x00000000feb00000)
object space 44032K, 99% used [0x00000000fc000000,0x00000000feac1f98,0x00000000feb00000)
Metaspace used 39918K, capacity 41768K, committed 41984K, reserved 1085440K
class space used 5183K, capacity 5512K, committed 5632K, reserved 1048576K
}

2.4. GC收集器日志

下面使用在JDK 8中常用的6种不同收集器组合进行测试,分别记录启动之后的两次Full GC,以及首次Full GC之前发生的GC情况

这里发生Full GC是因为元数据空间没有指定,使用了默认值21M导致,如果设置一下MetaspaceSize,就可以避免,只不过这里的目的就是为了看下各种收集器组合下的日志打印情况,方便分析比较。

2.4.1. UseParallelGC

Parallel Scavenge + Serial Old是默认收集器组合,其日志格式2.2中已经有过详细说明,可以通过PSYoungGen来识别

-Xms128m -Xmx128m -Xloggc:UseParallelGC.log -XX:+PrintGCDetails -XX:+PrintHeapAtGC ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
Java HotSpot(TM) 64-Bit Server VM (25.11-b03) for windows-amd64 JRE (1.8.0_11-b12), 
built on Jun 16 2014 20:57:32 by "java_re" with MS VC++ 10.0 (VS2010)
Memory: 4k page, physical 8243964k(4695156k free), swap 16486028k(11796044k free)
// ... ...

{Heap before GC invocations=1 (full 0):
PSYoungGen total 38400K, used 33280K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 100% used [0x00000000fd580000,0x00000000ff600000,0x00000000ff600000)
from space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
to space 5120K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffb00000)
ParOldGen total 87552K, used 0K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 0% used [0x00000000f8000000,0x00000000f8000000,0x00000000fd580000)
Metaspace used 10647K, capacity 10946K, committed 11136K, reserved 1058816K
class space used 1304K, capacity 1385K, committed 1408K, reserved 1048576K
0.532: [GC (Allocation Failure) [PSYoungGen: 33280K->5108K(38400K)] 33280K->5652K(125952K), 0.0072743 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=1 (full 0):
PSYoungGen total 38400K, used 5108K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ff600000,0x00000000ffafd010,0x00000000ffb00000)
to space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
ParOldGen total 87552K, used 544K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 0% used [0x00000000f8000000,0x00000000f80881f0,0x00000000fd580000)
Metaspace used 10647K, capacity 10946K, committed 11136K, reserved 1058816K
class space used 1304K, capacity 1385K, committed 1408K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=2 (full 0):
PSYoungGen total 38400K, used 38388K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 100% used [0x00000000fd580000,0x00000000ff600000,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ff600000,0x00000000ffafd010,0x00000000ffb00000)
to space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
ParOldGen total 87552K, used 596K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 0% used [0x00000000f8000000,0x00000000f80952e0,0x00000000fd580000)
Metaspace used 15961K, capacity 16370K, committed 16640K, reserved 1062912K
class space used 2090K, capacity 2181K, committed 2304K, reserved 1048576K
0.733: [GC (GCLocker Initiated GC) [PSYoungGen: 38388K->5099K(38400K)] 38984K->8071K(125952K), 0.0081548 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=2 (full 0):
PSYoungGen total 38400K, used 5099K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ffb00000,0x00000000ffffad38,0x0000000100000000)
to space 5120K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffb00000)
ParOldGen total 87552K, used 2972K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 3% used [0x00000000f8000000,0x00000000f82e71e8,0x00000000fd580000)
Metaspace used 15961K, capacity 16370K, committed 16640K, reserved 1062912K
class space used 2090K, capacity 2181K, committed 2304K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=3 (full 0):
PSYoungGen total 38400K, used 37219K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 96% used [0x00000000fd580000,0x00000000ff4de018,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ffb00000,0x00000000ffffad38,0x0000000100000000)
to space 5120K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffb00000)
ParOldGen total 87552K, used 2972K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 3% used [0x00000000f8000000,0x00000000f82e71e8,0x00000000fd580000)
Metaspace used 20831K, capacity 21284K, committed 21296K, reserved 1067008K
class space used 2737K, capacity 2852K, committed 2864K, reserved 1048576K
0.921: [GC (Metadata GC Threshold) [PSYoungGen: 37219K->5110K(38400K)] 40191K->12185K(125952K), 0.0080553 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=3 (full 0):
PSYoungGen total 38400K, used 5110K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ff600000,0x00000000ffafd908,0x00000000ffb00000)
to space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
ParOldGen total 87552K, used 7075K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 8% used [0x00000000f8000000,0x00000000f86e8d40,0x00000000fd580000)
Metaspace used 20831K, capacity 21284K, committed 21296K, reserved 1067008K
class space used 2737K, capacity 2852K, committed 2864K, reserved 1048576K
}
{Heap before GC invocations=4 (full 1):
PSYoungGen total 38400K, used 5110K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ff600000,0x00000000ffafd908,0x00000000ffb00000)
to space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
ParOldGen total 87552K, used 7075K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 8% used [0x00000000f8000000,0x00000000f86e8d40,0x00000000fd580000)
Metaspace used 20831K, capacity 21284K, committed 21296K, reserved 1067008K
class space used 2737K, capacity 2852K, committed 2864K, reserved 1048576K
0.929: [Full GC (Metadata GC Threshold) [PSYoungGen: 5110K->0K(38400K)]
[ParOldGen: 7075K->9066K(87552K)] 12185K->9066K(125952K),
[Metaspace: 20831K->20829K(1067008K)], 0.0239430 secs] [Times: user=0.13 sys=0.00, real=0.02 secs]
Heap after GC invocations=4 (full 1):
PSYoungGen total 38400K, used 0K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000ff600000)
from space 5120K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffb00000)
to space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
ParOldGen total 87552K, used 9066K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 10% used [0x00000000f8000000,0x00000000f88daad0,0x00000000fd580000)
Metaspace used 20829K, capacity 21278K, committed 21296K, reserved 1067008K
class space used 2737K, capacity 2851K, committed 2864K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=9 (full 1):
PSYoungGen total 33792K, used 33178K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 24064K, 97% used [0x00000000fd580000,0x00000000fec6e7e8,0x00000000fed00000)
from space 9728K, 99% used [0x00000000fed00000,0x00000000ff678220,0x00000000ff680000)
to space 9728K, 0% used [0x00000000ff680000,0x00000000ff680000,0x0000000100000000)
ParOldGen total 87552K, used 13977K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 15% used [0x00000000f8000000,0x00000000f8da6438,0x00000000fd580000)
Metaspace used 34213K, capacity 35448K, committed 35464K, reserved 1081344K
class space used 4428K, capacity 4644K, committed 4656K, reserved 1048576K
2.432: [GC (Metadata GC Threshold) [PSYoungGen: 33178K->9534K(28672K)] 47155K->25671K(116224K), 0.0099873 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=9 (full 1):
PSYoungGen total 28672K, used 9534K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 18944K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000fe800000)
from space 9728K, 98% used [0x00000000ff680000,0x00000000fffcf830,0x0000000100000000)
to space 12288K, 0% used [0x00000000fe800000,0x00000000fe800000,0x00000000ff400000)
ParOldGen total 87552K, used 16137K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 18% used [0x00000000f8000000,0x00000000f8fc2448,0x00000000fd580000)
Metaspace used 34213K, capacity 35448K, committed 35464K, reserved 1081344K
class space used 4428K, capacity 4644K, committed 4656K, reserved 1048576K
}
{Heap before GC invocations=10 (full 2):
PSYoungGen total 28672K, used 9534K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 18944K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000fe800000)
from space 9728K, 98% used [0x00000000ff680000,0x00000000fffcf830,0x0000000100000000)
to space 12288K, 0% used [0x00000000fe800000,0x00000000fe800000,0x00000000ff400000)
ParOldGen total 87552K, used 16137K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 18% used [0x00000000f8000000,0x00000000f8fc2448,0x00000000fd580000)
Metaspace used 34213K, capacity 35448K, committed 35464K, reserved 1081344K
class space used 4428K, capacity 4644K, committed 4656K, reserved 1048576K
2.442: [Full GC (Metadata GC Threshold) [PSYoungGen: 9534K->0K(28672K)]
[ParOldGen: 16137K->16404K(87552K)] 25671K->16404K(116224K),
[Metaspace: 34213K->34213K(1081344K)], 0.0926915 secs] [Times: user=0.33 sys=0.00, real=0.09 secs]
Heap after GC invocations=10 (full 2):
PSYoungGen total 28672K, used 0K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 18944K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000fe800000)
from space 9728K, 0% used [0x00000000ff680000,0x00000000ff680000,0x0000000100000000)
to space 12288K, 0% used [0x00000000fe800000,0x00000000fe800000,0x00000000ff400000)
ParOldGen total 87552K, used 16404K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 18% used [0x00000000f8000000,0x00000000f9005158,0x00000000fd580000)
Metaspace used 34213K, capacity 35448K, committed 35464K, reserved 1081344K
class space used 4428K, capacity 4644K, committed 4656K, reserved 1048576K
}
// ... ...
2.4.2. UseSerialGC

Serial + Serial Old组合收集器的日志与上面类似,可以通过DefNew来识别

-Xms128m -Xmx128m -XX:+UseSerialGC -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintHeapAtGC ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Java HotSpot(TM) 64-Bit Server VM (25.11-b03) for windows-amd64 JRE (1.8.0_11-b12), 
built on Jun 16 2014 20:57:32 by "java_re" with MS VC++ 10.0 (VS2010)
Memory: 4k page, physical 8243964k(4615528k free), swap 16486028k(11720224k free)
// ... ...

{Heap before GC invocations=0 (full 0):
def new generation total 39296K, used 34944K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 100% used [0x00000000f8000000, 0x00000000fa220000, 0x00000000fa220000)
from space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 0K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 0% used [0x00000000faaa0000, 0x00000000faaa0000, 0x00000000faaa0200, 0x0000000100000000)
Metaspace used 10928K, capacity 11288K, committed 11520K, reserved 1058816K
class space used 1348K, capacity 1432K, committed 1536K, reserved 1048576K
0.570: [GC (Allocation Failure) 0.570:
[DefNew: 34944K->4352K(39296K), 0.0095725 secs] 34944K->5602K(126720K), 0.0096809 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=1 (full 0):
def new generation total 39296K, used 4352K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa660000, 0x00000000faaa0000, 0x00000000faaa0000)
to space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
tenured generation total 87424K, used 1250K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 1% used [0x00000000faaa0000, 0x00000000fabd8b28, 0x00000000fabd8c00, 0x0000000100000000)
Metaspace used 10928K, capacity 11288K, committed 11520K, reserved 1058816K
class space used 1348K, capacity 1432K, committed 1536K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=1 (full 0):
def new generation total 39296K, used 39296K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 100% used [0x00000000f8000000, 0x00000000fa220000, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa660000, 0x00000000faaa0000, 0x00000000faaa0000)
to space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
tenured generation total 87424K, used 1250K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 1% used [0x00000000faaa0000, 0x00000000fabd8b28, 0x00000000fabd8c00, 0x0000000100000000)
Metaspace used 16515K, capacity 16882K, committed 17152K, reserved 1064960K
class space used 2151K, capacity 2245K, committed 2304K, reserved 1048576K
0.769: [GC (Allocation Failure) 0.769:
[DefNew: 39296K->4351K(39296K), 0.0127333 secs] 40546K->8888K(126720K), 0.0128138 secs]
[Times: user=0.01 sys=0.00, real=0.01 secs]
Heap after GC invocations=2 (full 0):
def new generation total 39296K, used 4351K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 99% used [0x00000000fa220000, 0x00000000fa65fff0, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 4536K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 5% used [0x00000000faaa0000, 0x00000000faf0e100, 0x00000000faf0e200, 0x0000000100000000)
Metaspace used 16515K, capacity 16882K, committed 17152K, reserved 1064960K
class space used 2151K, capacity 2245K, committed 2304K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=2 (full 0):
def new generation total 39296K, used 32282K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 79% used [0x00000000f8000000, 0x00000000f9b46a78, 0x00000000fa220000)
from space 4352K, 99% used [0x00000000fa220000, 0x00000000fa65fff0, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 4536K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 5% used [0x00000000faaa0000, 0x00000000faf0e100, 0x00000000faf0e200, 0x0000000100000000)
Metaspace used 20786K, capacity 21282K, committed 21296K, reserved 1067008K
class space used 2732K, capacity 2851K, committed 2864K, reserved 1048576K
0.938: [Full GC (Metadata GC Threshold) 0.938:
[Tenured: 4536K->10537K(87424K), 0.0245053 secs] 36818K->10537K(126720K),
[Metaspace: 20786K->20786K(1067008K)], 0.0245602 secs] [Times: user=0.03 sys=0.00, real=0.02 secs]
Heap after GC invocations=3 (full 1):
def new generation total 39296K, used 0K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 10537K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 12% used [0x00000000faaa0000, 0x00000000fb4ea738, 0x00000000fb4ea800, 0x0000000100000000)
Metaspace used 20784K, capacity 21276K, committed 21296K, reserved 1067008K
class space used 2731K, capacity 2850K, committed 2864K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=7 (full 1):
def new generation total 39296K, used 12627K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 23% used [0x00000000f8000000, 0x00000000f8814f88, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa220000, 0x00000000fa660000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 19295K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 22% used [0x00000000faaa0000, 0x00000000fbd77d20, 0x00000000fbd77e00, 0x0000000100000000)
Metaspace used 34206K, capacity 35448K, committed 35460K, reserved 1081344K
class space used 4428K, capacity 4644K, committed 4656K, reserved 1048576K
2.509: [Full GC (Metadata GC Threshold) 2.509:
[Tenured: 19295K->22165K(87424K), 0.0477709 secs] 31923K->22165K(126720K),
[Metaspace: 34206K->34206K(1081344K)], 0.0478283 secs] [Times: user=0.09 sys=0.00, real=0.05 secs]
Heap after GC invocations=8 (full 2):
def new generation total 39296K, used 0K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 22165K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 25% used [0x00000000faaa0000, 0x00000000fc045570, 0x00000000fc045600, 0x0000000100000000)
Metaspace used 34206K, capacity 35448K, committed 35460K, reserved 1081344K
class space used 4428K, capacity 4644K, committed 4656K, reserved 1048576K
}
// ... ...
2.4.3. UseParNewGC

ParNew + Serial Old组合收集器的日志也是类似

-Xms128m -Xmx128m -XX:+UseParNewGC -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintHeapAtGC ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Java HotSpot(TM) 64-Bit Server VM (25.11-b03) for windows-amd64 JRE (1.8.0_11-b12), 
built on Jun 16 2014 20:57:32 by "java_re" with MS VC++ 10.0 (VS2010)
Memory: 4k page, physical 8243964k(4601764k free), swap 16486028k(11694196k free)
// ... ...

{Heap before GC invocations=0 (full 0):
par new generation total 39296K, used 34944K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 100% used [0x00000000f8000000, 0x00000000fa220000, 0x00000000fa220000)
from space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 0K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 0% used [0x00000000faaa0000, 0x00000000faaa0000, 0x00000000faaa0200, 0x0000000100000000)
Metaspace used 10930K, capacity 11288K, committed 11520K, reserved 1058816K
class space used 1348K, capacity 1432K, committed 1536K, reserved 1048576K
0.578: [GC (Allocation Failure) 0.578:
[ParNew: 34944K->4352K(39296K), 0.0062061 secs] 34944K->5682K(126720K), 0.0063068 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=1 (full 0):
par new generation total 39296K, used 4352K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa660000, 0x00000000faaa0000, 0x00000000faaa0000)
to space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
tenured generation total 87424K, used 1330K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 1% used [0x00000000faaa0000, 0x00000000fabeca68, 0x00000000fabecc00, 0x0000000100000000)
Metaspace used 10930K, capacity 11288K, committed 11520K, reserved 1058816K
class space used 1348K, capacity 1432K, committed 1536K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=1 (full 0):
par new generation total 39296K, used 39296K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 100% used [0x00000000f8000000, 0x00000000fa220000, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa660000, 0x00000000faaa0000, 0x00000000faaa0000)
to space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
tenured generation total 87424K, used 1330K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 1% used [0x00000000faaa0000, 0x00000000fabeca68, 0x00000000fabecc00, 0x0000000100000000)
Metaspace used 16516K, capacity 16882K, committed 17152K, reserved 1064960K
class space used 2154K, capacity 2245K, committed 2304K, reserved 1048576K
0.768: [GC (Allocation Failure) 0.768:
[ParNew: 39296K->4352K(39296K), 0.0080396 secs] 40626K->9863K(126720K), 0.0081195 secs]
[Times: user=0.06 sys=0.00, real=0.01 secs]
Heap after GC invocations=2 (full 0):
par new generation total 39296K, used 4352K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa220000, 0x00000000fa660000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 5511K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 6% used [0x00000000faaa0000, 0x00000000fb001d28, 0x00000000fb001e00, 0x0000000100000000)
Metaspace used 16516K, capacity 16882K, committed 17152K, reserved 1064960K
class space used 2154K, capacity 2245K, committed 2304K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=2 (full 0):
par new generation total 39296K, used 31840K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 78% used [0x00000000f8000000, 0x00000000f9ad82b0, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa220000, 0x00000000fa660000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 5511K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 6% used [0x00000000faaa0000, 0x00000000fb001d28, 0x00000000fb001e00, 0x0000000100000000)
Metaspace used 20682K, capacity 21144K, committed 21296K, reserved 1067008K
class space used 2719K, capacity 2848K, committed 2944K, reserved 1048576K
0.935: [Full GC (Metadata GC Threshold) 0.935:
[Tenured: 5511K->11360K(87424K), 0.0256963 secs] 37351K->11360K(126720K),
[Metaspace: 20682K->20682K(1067008K)], 0.0257524 secs] [Times: user=0.03 sys=0.00, real=0.02 secs]
Heap after GC invocations=3 (full 1):
par new generation total 39296K, used 0K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 11360K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 12% used [0x00000000faaa0000, 0x00000000fb5b8368, 0x00000000fb5b8400, 0x0000000100000000)
Metaspace used 20680K, capacity 21138K, committed 21296K, reserved 1067008K
class space used 2719K, capacity 2847K, committed 2944K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=7 (full 1):
par new generation total 39296K, used 6925K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 7% used [0x00000000f8000000, 0x00000000f8283698, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa220000, 0x00000000fa660000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 21601K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 24% used [0x00000000faaa0000, 0x00000000fbfb8660, 0x00000000fbfb8800, 0x0000000100000000)
Metaspace used 33823K, capacity 35082K, committed 35200K, reserved 1079296K
class space used 4389K, capacity 4635K, committed 4736K, reserved 1048576K
2.413: [Full GC (Metadata GC Threshold) 2.413:
[Tenured: 21601K->19607K(87424K), 0.0502456 secs] 28527K->19607K(126720K),
[Metaspace: 33823K->33823K(1079296K)], 0.0503049 secs] [Times: user=0.06 sys=0.00, real=0.05 secs]
Heap after GC invocations=8 (full 2):
par new generation total 39296K, used 0K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
tenured generation total 87424K, used 19607K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
the space 87424K, 22% used [0x00000000faaa0000, 0x00000000fbdc5dc0, 0x00000000fbdc5e00, 0x0000000100000000)
Metaspace used 33823K, capacity 35082K, committed 35200K, reserved 1079296K
class space used 4389K, capacity 4635K, committed 4736K, reserved 1048576K
}
// ... ...
2.4.4. UseParallelOldGC

Parallel Scavenge + Parallel Old组合收集器的日志也是类似的

-Xms128m -Xmx128m -XX:+UseParallelOldGC -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintHeapAtGC ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
Java HotSpot(TM) 64-Bit Server VM (25.11-b03) for windows-amd64 JRE (1.8.0_11-b12), 
built on Jun 16 2014 20:57:32 by "java_re" with MS VC++ 10.0 (VS2010)
Memory: 4k page, physical 8243964k(4516440k free), swap 16486028k(11638248k free)
// ... ...

{Heap before GC invocations=1 (full 0):
PSYoungGen total 38400K, used 33280K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 100% used [0x00000000fd580000,0x00000000ff600000,0x00000000ff600000)
from space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
to space 5120K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffb00000)
ParOldGen total 87552K, used 0K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 0% used [0x00000000f8000000,0x00000000f8000000,0x00000000fd580000)
Metaspace used 10674K, capacity 11010K, committed 11136K, reserved 1058816K
class space used 1306K, capacity 1385K, committed 1408K, reserved 1048576K
0.540: [GC (Allocation Failure) [PSYoungGen: 33280K->5107K(38400K)] 33280K->5665K(125952K), 0.0057455 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=1 (full 0):
PSYoungGen total 38400K, used 5107K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ff600000,0x00000000ffafcc38,0x00000000ffb00000)
to space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
ParOldGen total 87552K, used 558K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 0% used [0x00000000f8000000,0x00000000f808b850,0x00000000fd580000)
Metaspace used 10674K, capacity 11010K, committed 11136K, reserved 1058816K
class space used 1306K, capacity 1385K, committed 1408K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=2 (full 0):
PSYoungGen total 38400K, used 38387K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 100% used [0x00000000fd580000,0x00000000ff600000,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ff600000,0x00000000ffafcc38,0x00000000ffb00000)
to space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
ParOldGen total 87552K, used 558K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 0% used [0x00000000f8000000,0x00000000f808b850,0x00000000fd580000)
Metaspace used 15977K, capacity 16370K, committed 16640K, reserved 1062912K
class space used 2087K, capacity 2181K, committed 2304K, reserved 1048576K
0.722: [GC (Allocation Failure) [PSYoungGen: 38387K->5104K(38400K)] 38945K->8010K(125952K), 0.0073028 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=2 (full 0):
PSYoungGen total 38400K, used 5104K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ffb00000,0x00000000ffffc188,0x0000000100000000)
to space 5120K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffb00000)
ParOldGen total 87552K, used 2906K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 3% used [0x00000000f8000000,0x00000000f82d6940,0x00000000fd580000)
Metaspace used 15977K, capacity 16370K, committed 16640K, reserved 1062912K
class space used 2087K, capacity 2181K, committed 2304K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=3 (full 0):
PSYoungGen total 38400K, used 37382K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 96% used [0x00000000fd580000,0x00000000ff505968,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ffb00000,0x00000000ffffc188,0x0000000100000000)
to space 5120K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffb00000)
ParOldGen total 87552K, used 2906K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 3% used [0x00000000f8000000,0x00000000f82d6940,0x00000000fd580000)
Metaspace used 20742K, capacity 21162K, committed 21296K, reserved 1067008K
class space used 2727K, capacity 2841K, committed 2944K, reserved 1048576K
0.899: [GC (Metadata GC Threshold) [PSYoungGen: 37382K->5114K(38400K)] 40289K->12060K(125952K), 0.0061182 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=3 (full 0):
PSYoungGen total 38400K, used 5114K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ff600000,0x00000000ffafebe0,0x00000000ffb00000)
to space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
ParOldGen total 87552K, used 6945K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 7% used [0x00000000f8000000,0x00000000f86c85b0,0x00000000fd580000)
Metaspace used 20742K, capacity 21162K, committed 21296K, reserved 1067008K
class space used 2727K, capacity 2841K, committed 2944K, reserved 1048576K
}
{Heap before GC invocations=4 (full 1):
PSYoungGen total 38400K, used 5114K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000ff600000)
from space 5120K, 99% used [0x00000000ff600000,0x00000000ffafebe0,0x00000000ffb00000)
to space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
ParOldGen total 87552K, used 6945K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 7% used [0x00000000f8000000,0x00000000f86c85b0,0x00000000fd580000)
Metaspace used 20742K, capacity 21162K, committed 21296K, reserved 1067008K
class space used 2727K, capacity 2841K, committed 2944K, reserved 1048576K
0.905: [Full GC (Metadata GC Threshold) [PSYoungGen: 5114K->0K(38400K)]
[ParOldGen: 6945K->8972K(87552K)] 12060K->8972K(125952K),
[Metaspace: 20742K->20740K(1067008K)], 0.0226491 secs] [Times: user=0.06 sys=0.02, real=0.02 secs]
Heap after GC invocations=4 (full 1):
PSYoungGen total 38400K, used 0K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 33280K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000ff600000)
from space 5120K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffb00000)
to space 5120K, 0% used [0x00000000ffb00000,0x00000000ffb00000,0x0000000100000000)
ParOldGen total 87552K, used 8972K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 10% used [0x00000000f8000000,0x00000000f88c3068,0x00000000fd580000)
Metaspace used 20740K, capacity 21156K, committed 21296K, reserved 1067008K
class space used 2726K, capacity 2840K, committed 2944K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=9 (full 1):
PSYoungGen total 33792K, used 28150K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 24064K, 76% used [0x00000000fd580000,0x00000000fe783138,0x00000000fed00000)
from space 9728K, 99% used [0x00000000fed00000,0x00000000ff67aa50,0x00000000ff680000)
to space 9728K, 0% used [0x00000000ff680000,0x00000000ff680000,0x0000000100000000)
ParOldGen total 87552K, used 14074K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 16% used [0x00000000f8000000,0x00000000f8dbe880,0x00000000fd580000)
Metaspace used 33844K, capacity 35080K, committed 35200K, reserved 1079296K
class space used 4391K, capacity 4636K, committed 4736K, reserved 1048576K
2.439: [GC (Metadata GC Threshold) [PSYoungGen: 28150K->9290K(28672K)] 42225K->25476K(116224K), 0.0076845 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=9 (full 1):
PSYoungGen total 28672K, used 9290K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 18944K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000fe800000)
from space 9728K, 95% used [0x00000000ff680000,0x00000000fff92968,0x0000000100000000)
to space 12288K, 0% used [0x00000000fe800000,0x00000000fe800000,0x00000000ff400000)
ParOldGen total 87552K, used 16186K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 18% used [0x00000000f8000000,0x00000000f8fce890,0x00000000fd580000)
Metaspace used 33844K, capacity 35080K, committed 35200K, reserved 1079296K
class space used 4391K, capacity 4636K, committed 4736K, reserved 1048576K
}
{Heap before GC invocations=10 (full 2):
PSYoungGen total 28672K, used 9290K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 18944K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000fe800000)
from space 9728K, 95% used [0x00000000ff680000,0x00000000fff92968,0x0000000100000000)
to space 12288K, 0% used [0x00000000fe800000,0x00000000fe800000,0x00000000ff400000)
ParOldGen total 87552K, used 16186K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 18% used [0x00000000f8000000,0x00000000f8fce890,0x00000000fd580000)
Metaspace used 33844K, capacity 35080K, committed 35200K, reserved 1079296K
class space used 4391K, capacity 4636K, committed 4736K, reserved 1048576K
2.447: [Full GC (Metadata GC Threshold) [PSYoungGen: 9290K->0K(28672K)]
[ParOldGen: 16186K->16035K(87552K)] 25476K->16035K(116224K),
[Metaspace: 33844K->33844K(1079296K)], 0.0569332 secs] [Times: user=0.20 sys=0.00, real=0.06 secs]
Heap after GC invocations=10 (full 2):
PSYoungGen total 28672K, used 0K [0x00000000fd580000, 0x0000000100000000, 0x0000000100000000)
eden space 18944K, 0% used [0x00000000fd580000,0x00000000fd580000,0x00000000fe800000)
from space 9728K, 0% used [0x00000000ff680000,0x00000000ff680000,0x0000000100000000)
to space 12288K, 0% used [0x00000000fe800000,0x00000000fe800000,0x00000000ff400000)
ParOldGen total 87552K, used 16035K [0x00000000f8000000, 0x00000000fd580000, 0x00000000fd580000)
object space 87552K, 18% used [0x00000000f8000000,0x00000000f8fa8d48,0x00000000fd580000)
Metaspace used 33844K, capacity 35080K, committed 35200K, reserved 1079296K
class space used 4391K, capacity 4636K, committed 4736K, reserved 1048576K
}
// ... ...
2.4.5. UseConcMarkSweepGC

对于Minor GC的日志与上面还是一样,这里主要看下老年代CMS收集的日志:

  • CMS Initial Mark,初始标记阶段,具体后面表示[(老年代使用量) 老年代总量] (堆使用量) 堆总量

  • CMS-concurrent-mark,并发标记阶段,与用户线程同时执行

  • CMS-concurrent-preclean,重新标记阶段,上一个阶段在运行过程中,一些对象的引用已经发生了变化,然后JVM会标记堆中这个区域为Dirty Card,以及能够从Dirty Card到达的对象也会被标记,另外,做一些必要的清理操作

  • CMS-concurrent-abortable-preclean,这个阶段尝试去承担Final Remark阶段中足够多的工作,其持续时间依赖很多因素,由于这个阶段是重复的做相同的事情直到达到aboart的条件(比如:重复的次数、多少量的工作、持续的时间等等)之一才会停止,这个阶段在很大程度上影响着即将来临的Final Remark的停顿

  • CMS Final Remark,该阶段负责标记整个年老代中所有存活的对象,通常CMS会尽量在年轻代是足够干净的时候执行Final Remark阶段,目的是消除连续出现STW的情况,其中
    YG occupancy:表示年轻代当前使用量和总量;
    Rescan (parallel):表示重新标记存活对象所花费的时间STW;
    weak refs processing:第一个子阶段,处理弱引用;
    class unloading:第二个子阶段,类卸载;
    scrub symbol table:第三个子阶段,清理符号表;
    scrub string table:第四个子阶段,清理字符串表;
    CMS-remark:最后表示收集之后,老年代和堆的使用量和总量;

  • CMS-concurrent-sweep,并发清除阶段,与用户线程并发执行,移除已标记死亡的对象,并回收它们占用的空间

  • CMS-concurrent-reset,重置CMS算法内部的数据结构,为下一次CMS收集做准备

-Xms128m -Xmx128m -XX:+UseConcMarkSweepGC -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintHeapAtGC ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
Java HotSpot(TM) 64-Bit Server VM (25.11-b03) for windows-amd64 JRE (1.8.0_11-b12), 
built on Jun 16 2014 20:57:32 by "java_re" with MS VC++ 10.0 (VS2010)
Memory: 4k page, physical 8243964k(4539572k free), swap 16486028k(11652936k free)
// ... ...

{Heap before GC invocations=0 (full 0):
par new generation total 39296K, used 34944K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 100% used [0x00000000f8000000, 0x00000000fa220000, 0x00000000fa220000)
from space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
concurrent mark-sweep generation total 87424K, used 0K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
Metaspace used 10888K, capacity 11218K, committed 11520K, reserved 1058816K
class space used 1345K, capacity 1431K, committed 1536K, reserved 1048576K
0.503: [GC (Allocation Failure) 0.503:
[ParNew: 34944K->4351K(39296K), 0.0056204 secs] 34944K->5632K(126720K), 0.0057603 secs]
[Times: user=0.05 sys=0.01, real=0.01 secs]
Heap after GC invocations=1 (full 0):
par new generation total 39296K, used 4351K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 99% used [0x00000000fa660000, 0x00000000faa9fff8, 0x00000000faaa0000)
to space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
concurrent mark-sweep generation total 87424K, used 1280K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
Metaspace used 10888K, capacity 11218K, committed 11520K, reserved 1058816K
class space used 1345K, capacity 1431K, committed 1536K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=1 (full 0):
par new generation total 39296K, used 39295K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 100% used [0x00000000f8000000, 0x00000000fa220000, 0x00000000fa220000)
from space 4352K, 99% used [0x00000000fa660000, 0x00000000faa9fff8, 0x00000000faaa0000)
to space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
concurrent mark-sweep generation total 87424K, used 1280K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
Metaspace used 16519K, capacity 16946K, committed 17152K, reserved 1064960K
class space used 2155K, capacity 2245K, committed 2304K, reserved 1048576K
0.689: [GC (Allocation Failure) 0.689:
[ParNew: 39295K->4352K(39296K), 0.0111590 secs] 40576K->10427K(126720K), 0.0112447 secs]
[Times: user=0.05 sys=0.02, real=0.01 secs]
Heap after GC invocations=2 (full 0):
par new generation total 39296K, used 4352K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa220000, 0x00000000fa660000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
concurrent mark-sweep generation total 87424K, used 6075K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
Metaspace used 16519K, capacity 16946K, committed 17152K, reserved 1064960K
class space used 2155K, capacity 2245K, committed 2304K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=2 (full 0):
par new generation total 39296K, used 39296K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 100% used [0x00000000f8000000, 0x00000000fa220000, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa220000, 0x00000000fa660000, 0x00000000fa660000)
to space 4352K, 0% used [0x00000000fa660000, 0x00000000fa660000, 0x00000000faaa0000)
concurrent mark-sweep generation total 87424K, used 6075K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
Metaspace used 22224K, capacity 22736K, committed 22880K, reserved 1069056K
class space used 2908K, capacity 3028K, committed 3072K, reserved 1048576K
0.928: [GC (Allocation Failure) 0.928:
[ParNew: 39296K->4352K(39296K), 0.0055065 secs] 45371K->13772K(126720K), 0.0055665 secs]
[Times: user=0.00 sys=0.00, real=0.01 secs]
Heap after GC invocations=3 (full 0):
par new generation total 39296K, used 4352K [0x00000000f8000000, 0x00000000faaa0000, 0x00000000faaa0000)
eden space 34944K, 0% used [0x00000000f8000000, 0x00000000f8000000, 0x00000000fa220000)
from space 4352K, 100% used [0x00000000fa660000, 0x00000000faaa0000, 0x00000000faaa0000)
to space 4352K, 0% used [0x00000000fa220000, 0x00000000fa220000, 0x00000000fa660000)
concurrent mark-sweep generation total 87424K, used 9420K [0x00000000faaa0000, 0x0000000100000000, 0x0000000100000000)
Metaspace used 22224K, capacity 22736K, committed 22880K, reserved 1069056K
class space used 2908K, capacity 3028K, committed 3072K, reserved 1048576K
}
// ... ...

0.934: [GC (CMS Initial Mark) [1 CMS-initial-mark: 9420K(87424K)] 14189K(126720K), 0.0008179 secs]
[Times: user=0.00 sys=0.00, real=0.00 secs]
0.935: [CMS-concurrent-mark-start]
0.940: [CMS-concurrent-mark: 0.005/0.005 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
0.940: [CMS-concurrent-preclean-start]
0.941: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
0.942: [GC (CMS Final Remark)
[YG occupancy: 5671 K (39296 K)]0.942:
[Rescan (parallel) , 0.0010980 secs]0.943:
[weak refs processing, 0.0000167 secs]0.943:
[class unloading, 0.0048647 secs]0.948:
[scrub symbol table, 0.0013905 secs]0.949:
[scrub string table, 0.0002502 secs]
[1 CMS-remark: 9420K(87424K)] 15091K(126720K), 0.0086927 secs] [Times: user=0.06 sys=0.00, real=0.01 secs]
0.951: [CMS-concurrent-sweep-start]
0.953: [CMS-concurrent-sweep: 0.002/0.002 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
0.953: [CMS-concurrent-reset-start]
0.953: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
// ... ...

4.768: [GC (CMS Initial Mark) [1 CMS-initial-mark: 21002K(87424K)] 47054K(126720K), 0.0039377 secs]
[Times: user=0.00 sys=0.00, real=0.00 secs]
4.772: [CMS-concurrent-mark-start]
4.787: [CMS-concurrent-mark: 0.015/0.015 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
4.787: [CMS-concurrent-preclean-start]
4.788: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
4.788: [CMS-concurrent-abortable-preclean-start]
CMS: abort preclean due to time 9.837: [CMS-concurrent-abortable-preclean: 1.358/5.049 secs]
[Times: user=1.34 sys=0.02, real=5.05 secs]
9.837: [GC (CMS Final Remark)
[YG occupancy: 26051 K (39296 K)]9.837:
[Rescan (parallel) , 0.0040500 secs]9.841:
[weak refs processing, 0.0000273 secs]9.841:
[class unloading, 0.0129822 secs]9.854:
[scrub symbol table, 0.0031053 secs]9.858:
[scrub string table, 0.0004949 secs]
[1 CMS-remark: 21002K(87424K)] 47054K(126720K), 0.0230491 secs] [Times: user=0.02 sys=0.00, real=0.02 secs]
9.861: [CMS-concurrent-sweep-start]
9.866: [CMS-concurrent-sweep: 0.005/0.005 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
9.866: [CMS-concurrent-reset-start]
9.866: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2.4.6. UseG1GC

这里主要看下G1对年轻代收集的日志,如果触发了Full GC,则与之前也差不多

  • 行11:[GC pause (G1 Evacuation Pause) (young), 0.0021238 secs]

首行按顺序分别表示:GC停顿(GC停顿的原因是疏散转移)(GC的区域是年轻代)GC总耗时

  • 行12:[Parallel Time: 1.3 ms, GC Workers: 4]

由4个worker线程并行执行,耗时 1.3ms

  • 行13:[GC Worker Start (ms): Min: 221.7, Avg: 221.7, Max: 221.7, Diff: 0.0]

表示GC的worker线程启动时,相对于pause开始的时间,如果Min和Max相差很大,则表示其它进程所使用的线程过多,挤占了GC的CPU时间

  • 行14:[Ext Root Scanning (ms): Min: 0.2, Avg: 0.2, Max: 0.3, Diff: 0.0, Sum: 1.0]

表示扫描堆外(non-heap)的root所花费的时间,比如JNI引用, JVM的系统root等,Sum指的是CPU时间

  • 行18:[Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.1]

扫描实际代码中的Root所花费的时间

  • 行19:[Object Copy (ms): Min: 0.9, Avg: 1.0, Max: 1.0, Diff: 0.1, Sum: 3.9]

拷贝收集区内存活对象所花费的时间

  • 行20:[Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]

GC的worker线程用了多长时间来确保自身可以安全地停止, 这段时间什么也不用做, stop之后该线程即终止运行

  • 行21:[GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]

一些琐碎的小活动,在GC日志中不值得单独列出来

  • 行22:[GC Worker Total (ms): Min: 1.3, Avg: 1.3, Max: 1.3, Diff: 0.0, Sum: 5.1]

GC的worker线程的工作时间总计

  • 行23:[GC Worker End (ms): Min: 223.0, Avg: 223.0, Max: 223.0, Diff: 0.0]

GC的worker线程的完成时间,通常这部分数字应该大致相等,否则说明有太多的线程被挂起,很可能是因为坏邻居效应所导致

  • 行24:[Code Root Fixup: 0.1 ms]

释放用于管理并行活动的内部数据,一般接近于零,这是串行执行的过程

  • 行27:[Other: 0.7 ms]

其他活动消耗的时间, 其中有很多是并行执行的

  • 行32:[Eden: 6144.0K(6144.0K)->0.0B(12.0M) Survivors: 0.0B->1024.0K Heap: 6144.0K(128.0M)->1736.4K(128.0M)]

收集前后,Eden区、Survivor区、以及整个堆的 使用量(总容量)

-Xms128m -Xmx128m -XX:+UseG1GC -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintHeapAtGC ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
Java HotSpot(TM) 64-Bit Server VM (25.11-b03) for windows-amd64 JRE (1.8.0_11-b12), 
built on Jun 16 2014 20:57:32 by "java_re" with MS VC++ 10.0 (VS2010)
Memory: 4k page, physical 8243964k(4539860k free), swap 16486028k(11665520k free)
// ... ...

{Heap before GC invocations=0 (full 0):
garbage-first heap total 131072K, used 6144K [0x00000000f8000000, 0x0000000100000000, 0x0000000100000000)
region size 1024K, 6 young (6144K), 0 survivors (0K)
Metaspace used 4279K, capacity 5268K, committed 5504K, reserved 1056768K
class space used 496K, capacity 528K, committed 640K, reserved 1048576K
0.222: [GC pause (G1 Evacuation Pause) (young), 0.0021238 secs]
[Parallel Time: 1.3 ms, GC Workers: 4]
[GC Worker Start (ms): Min: 221.7, Avg: 221.7, Max: 221.7, Diff: 0.0]
[Ext Root Scanning (ms): Min: 0.2, Avg: 0.2, Max: 0.3, Diff: 0.0, Sum: 1.0]
[Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[Processed Buffers: Min: 0, Avg: 0.0, Max: 0, Diff: 0, Sum: 0]
[Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.1]
[Object Copy (ms): Min: 0.9, Avg: 1.0, Max: 1.0, Diff: 0.1, Sum: 3.9]
[Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
[GC Worker Total (ms): Min: 1.3, Avg: 1.3, Max: 1.3, Diff: 0.0, Sum: 5.1]
[GC Worker End (ms): Min: 223.0, Avg: 223.0, Max: 223.0, Diff: 0.0]
[Code Root Fixup: 0.1 ms]
[Code Root Migration: 0.0 ms]
[Clear CT: 0.0 ms]
[Other: 0.7 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 0.7 ms] // 处理非强引用(non-strong)的时间,进行清理或者决定是否需要清理
[Ref Enq: 0.0 ms] // 用来将剩下的non-strong引用,排列到合适的 ReferenceQueue中
[Free CSet: 0.0 ms] // 将回收集中被释放的小堆归还所消耗的时间,以便他们能用来分配新的对象
[Eden: 6144.0K(6144.0K)->0.0B(12.0M) Survivors: 0.0B->1024.0K Heap: 6144.0K(128.0M)->1736.4K(128.0M)]
Heap after GC invocations=1 (full 0):
garbage-first heap total 131072K, used 1736K [0x00000000f8000000, 0x0000000100000000, 0x0000000100000000)
region size 1024K, 1 young (1024K), 1 survivors (1024K)
Metaspace used 4279K, capacity 5268K, committed 5504K, reserved 1056768K
class space used 496K, capacity 528K, committed 640K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=1 (full 0):
garbage-first heap total 131072K, used 14024K [0x00000000f8000000, 0x0000000100000000, 0x0000000100000000)
region size 1024K, 13 young (13312K), 1 survivors (1024K)
Metaspace used 8072K, capacity 8306K, committed 8576K, reserved 1056768K
class space used 986K, capacity 1037K, committed 1152K, reserved 1048576K
0.438: [GC pause (G1 Evacuation Pause) (young), 0.0045991 secs]
[Parallel Time: 2.5 ms, GC Workers: 4]
[GC Worker Start (ms): Min: 437.9, Avg: 437.9, Max: 438.0, Diff: 0.1]
[Ext Root Scanning (ms): Min: 0.1, Avg: 0.6, Max: 1.6, Diff: 1.5, Sum: 2.4]
[Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.2]
[Processed Buffers: Min: 0, Avg: 1.3, Max: 3, Diff: 3, Sum: 5]
[Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.1]
[Object Copy (ms): Min: 1.0, Avg: 1.8, Max: 2.2, Diff: 1.2, Sum: 7.2]
[Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[GC Worker Total (ms): Min: 2.4, Avg: 2.5, Max: 2.5, Diff: 0.1, Sum: 10.0]
[GC Worker End (ms): Min: 440.4, Avg: 440.4, Max: 440.4, Diff: 0.0]
[Code Root Fixup: 0.1 ms]
[Code Root Migration: 0.1 ms]
[Clear CT: 0.1 ms]
[Other: 1.7 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 1.7 ms]
[Ref Enq: 0.0 ms]
[Free CSet: 0.0 ms]
[Eden: 12.0M(12.0M)->0.0B(69.0M) Survivors: 1024.0K->2048.0K Heap: 13.7M(128.0M)->5819.8K(128.0M)]
Heap after GC invocations=2 (full 0):
garbage-first heap total 131072K, used 5819K [0x00000000f8000000, 0x0000000100000000, 0x0000000100000000)
region size 1024K, 2 young (2048K), 2 survivors (2048K)
Metaspace used 8072K, capacity 8306K, committed 8576K, reserved 1056768K
class space used 986K, capacity 1037K, committed 1152K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=2 (full 0):
garbage-first heap total 131072K, used 72379K [0x00000000f8000000, 0x0000000100000000, 0x0000000100000000)
region size 1024K, 67 young (68608K), 2 survivors (2048K)
Metaspace used 19381K, capacity 19808K, committed 20096K, reserved 1067008K
class space used 2521K, capacity 2642K, committed 2688K, reserved 1048576K
0.874: [GC pause (G1 Evacuation Pause) (young), 0.0125903 secs]
[Parallel Time: 7.2 ms, GC Workers: 4]
[GC Worker Start (ms): Min: 874.2, Avg: 877.4, Max: 881.1, Diff: 7.0]
[Ext Root Scanning (ms): Min: 0.0, Avg: 0.5, Max: 1.3, Diff: 1.3, Sum: 1.8]
[Update RS (ms): Min: 0.0, Avg: 0.2, Max: 0.5, Diff: 0.5, Sum: 0.7]
[Processed Buffers: Min: 0, Avg: 2.8, Max: 7, Diff: 7, Sum: 11]
[Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.2]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.2]
[Object Copy (ms): Min: 0.2, Avg: 3.1, Max: 5.8, Diff: 5.7, Sum: 12.4]
[Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.2]
[GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[GC Worker Total (ms): Min: 0.2, Avg: 3.9, Max: 7.2, Diff: 7.0, Sum: 15.6]
[GC Worker End (ms): Min: 881.3, Avg: 881.3, Max: 881.3, Diff: 0.0]
[Code Root Fixup: 0.2 ms]
[Code Root Migration: 0.2 ms]
[Clear CT: 0.0 ms]
[Other: 5.0 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 4.9 ms]
[Ref Enq: 0.0 ms]
[Free CSet: 0.0 ms]
[Eden: 65.0M(65.0M)->0.0B(67.0M) Survivors: 2048.0K->9216.0K Heap: 70.7M(128.0M)->17.4M(128.0M)]
Heap after GC invocations=3 (full 0):
garbage-first heap total 131072K, used 17862K [0x00000000f8000000, 0x0000000100000000, 0x0000000100000000)
region size 1024K, 9 young (9216K), 9 survivors (9216K)
Metaspace used 19381K, capacity 19808K, committed 20096K, reserved 1067008K
class space used 2521K, capacity 2642K, committed 2688K, reserved 1048576K
}
// ... ...

{Heap before GC invocations=3 (full 0):
garbage-first heap total 131072K, used 26054K [0x00000000f8000000, 0x0000000100000000, 0x0000000100000000)
region size 1024K, 18 young (18432K), 9 survivors (9216K)
Metaspace used 20692K, capacity 21170K, committed 21296K, reserved 1067008K
class space used 2716K, capacity 2841K, committed 2944K, reserved 1048576K
0.942: [Full GC (Metadata GC Threshold) 26M->5742K(128M), 0.0250756 secs]
[Eden: 9216.0K(67.0M)->0.0B(76.0M) Survivors: 9216.0K->0.0B Heap: 26.3M(128.0M)->5742.3K(128.0M)],
[Metaspace: 20692K->20691K(1067008K)]
Heap after GC invocations=4 (full 1):
garbage-first heap total 131072K, used 5742K [0x00000000f8000000, 0x0000000100000000, 0x0000000100000000)
region size 1024K, 0 young (0K), 0 survivors (0K)
Metaspace used 20691K, capacity 21164K, committed 21296K, reserved 1067008K
class space used 2715K, capacity 2840K, committed 2944K, reserved 1048576K
}

{Heap before GC invocations=5 (full 1):
garbage-first heap total 131072K, used 78958K [0x00000000f8000000, 0x0000000100000000, 0x0000000100000000)
region size 1024K, 72 young (73728K), 10 survivors (10240K)
Metaspace used 33931K, capacity 35150K, committed 35276K, reserved 1079296K
class space used 4394K, capacity 4637K, committed 4736K, reserved 1048576K
2.527: [Full GC (Metadata GC Threshold) 77M->17M(128M), 0.0661952 secs]
[Eden: 62.0M(66.0M)->0.0B(76.0M) Survivors: 10.0M->0.0B Heap: 77.9M(128.0M)->17.6M(128.0M)],
[Metaspace: 33931K->33931K(1079296K)]
Heap after GC invocations=6 (full 2):
garbage-first heap total 131072K, used 18027K [0x00000000f8000000, 0x0000000100000000, 0x0000000100000000)
region size 1024K, 0 young (0K), 0 survivors (0K)
Metaspace used 33931K, capacity 35150K, committed 35276K, reserved 1079296K
class space used 4394K, capacity 4637K, committed 4736K, reserved 1048576K
}
// ... ...

3. 附录:JVM参数

这里整理一些常用的JVM参数,参数使用方式一般有两种,即

  • -XX:+/-<option>:表示开启/关闭option参数
  • -XX:<option>=<value>:表示将option参数的值设置为value
    内存参数:
    -Xms 初始堆大小,比如:-Xms1024m
    -Xmx 最大堆大小,比如:-Xmx1024m。一般会将-Xmx和-Xms设置成一样,避免JVM内存自动扩展
    -Xmn 新生代大小,比如:-Xmn512m。Sun官方推荐配置为整个堆的3/8
    -Xss 虚拟机栈大小,比如:-Xss128k。JDK 5.0之后默认为1M,之前为256K。
    减小栈可以生成更多的线程,但也不能没有限制,经验值在3000~5000左右。
    对于通常的小应用,如果栈不是很深,256k应该够用了
    -Xoss 本地方法栈的大小,比如:-Xoss128k。
    HotSpot并不区分虚拟机栈和本地方法栈,因此在HotSpot中该参数无效
    NewRatio 新生代与老年代的比值,比如:-XX:NewRatio=4,表示新生代/老年代=1/4,
    新生代占整个堆的1/5。如果Xms = Xmx,并设置了Xmn的情况下,则此参数无效。
    SurvivorRatio Eden区与Survivor区的比值,默认8,表示Survivor/Eden=1/8,整个新生代的划分为8:1:1
    MetaspaceSize 初始元数据空间大小,默认21M
    MaxMetaspaceSize 最大元数据空间大小
    MinHeapFreeRatio 当堆空余比例小于MinHeapFreeRatio时,自动扩展堆直到-Xmx限制,默认40%
    MaxHeapFreeRatio 当堆空余比例大于MaxHeapFreeRatio时,自动压缩堆直到-Xms限制,默认70%
    GC参数:
    MaxTenuringThreshold 对象晋升到老年代的年龄,默认为15。对象每经过一次Minor GC之后,年龄就会加1
    PretenureSizeThreshold 直接晋升到老年代的对象大小,单位为字节,无默认值
    UseAdaptiveSizePolicy 是否动态调整Java堆中各个区域大小,以及对象进入老年代的年龄,默认开启
    HandlePromotionFailure 是否允许分配担保失败,即老年代的剩余空间不足以应付新生代的整个Eden和Survivor区的所有对象都存活的极端情况,默认开启
    ParallelGCThreads 用户线程冻结期间,并行GC进行内存回收的线程数
    UseGCOverheadLimt 禁止GC过程无限制的执行,如果过于频繁,则直接OutOfMemory异常,默认开启
    UseTLAB 优先在本地线程缓冲区中分配对象,避免内存分配时的锁定过程,server模式下默认开启
    GC收集器参数:
    UseParallelGC 使用Parallel Scavenge + Serial Old进行垃圾回收,server模式下的默认值
    GCTimeRatio GC时间占用比率,默认99,表示允许1%的时间用于GC。仅在使用Parallel Scavenge时生效
    MaxGCPauseMillis GC最大停顿时间,无默认值。仅在使用Parallel Scavenge时生效
    UseSerialGC 使用Serial + Serial Old进行垃圾回收,Client模式下的默认值
    UseConcMarkSweepGC 使用ParNew + CMS进行垃圾回收
    同时Serial Old作为CMS出现Concurrent Mode Failure失败后的备用收集器使用
    CMSInitiatingOccupancyFraction 老年代使用率达到多少后触发垃圾收集,默认92%。仅在使用CMS收集器时生效
    UseCMSCompactAtFullCollection 不得不进行Full GC时,进行内存碎片整理,默认开启。仅在使用CMS收集器时生效
    CMSFullGCsBeforeCompaction 完成多少次垃圾收集后进行一次内存碎片整理,默认为0。仅在使用CMS收集器时生效
    UseParNewGC 使用ParNew + Serial Old的进行垃圾回收
    UseG1GC 使用G1收集器进行垃圾回收,JDK 9之后server模式下的默认值
    G1HeapRegionSize=n 设置Region大小,并非最终值
    MaxGCPauseMillis 设置G1收集过程目标时间,非硬性条件,默认200ms
    G1NewSizePercent 新生代最小值,默认5%
    G1MaxNewSizePercent 新生代最大值,默认60%
    UseParallelOldGC 使用Parallel Scavenge + Parallel Old进行垃圾回收
    即时编译参数:
    CompileThreshold 当函数的调用次数超过多少次时,JIT将字节码编译成本地机器码。
    client模式下默认为1500,server下默认为10000
    线程相关参数:
    UseSpinning 是否启用自旋锁,默认开启
    PreBlockSpin 使用自旋锁时的自旋次数,默认为10次
    UseThreadPriorities 使用本地线程优先级,默认开启
    UseBiasedLocking 是否启用偏向锁,默认开启
    UseFastAccessorMethods 当频繁反射执行某个方法时,生成字节码以加快反射的执行速度,默认开启
    调试参数:
    -verbose:class 打印类加载信息
    TraceClassLoading 打印类加载信息,类似-verbose:class
    TraceClassUnloading 打印类卸载信息
    HeapDumpOnOutOfMemoryError OOM时是否生成堆转储快照,默认关闭
    HeapDumpPath 堆转储生成文件路径
    OnOutOfMemoryError 发生OOM时的操作,比如执行脚本发送邮件


参考:

  1. Copyright ©《深入理解java虚拟机》
  2. https://www.cnblogs.com/cdfive2018/p/12320687.html
  3. http://47.240.95.151/2020/11/25/jvm-learning-jit/
  4. http://thinkhejie.github.io/2016/05/05/JVM%E7%B3%BB%E5%88%97_06/
  5. https://blog.csdn.net/u022812849/article/details/113728597
  6. https://shipilev.net/jvm/anatomy-quarks/9-jni-critical-gclocker/
  7. https://blog.csdn.net/FoolishAndStupid/article/details/78078238
  8. https://tech.meituan.com/2016/09/23/g1.html