当前位置: 首页 > news >正文

湘潭网站建设方案案例上海网站设计公司

湘潭网站建设方案案例,上海网站设计公司,找个做游戏的视频网站好,曰本真人做爰免费网站目录 一、JVM Optimization 1、G1 1、G1内存模型 2、基础概念 3、G1特点: 4、CMS日志分析 5、G1日志分析 2、GC参数 2.1、GC常用参数 2.2、Parallel常用参数 2.3、CMS常用参数 2.4、G1常用参数 一、JVM Optimization 1、G1 G1官网说明:Gar…

目录

一、JVM Optimization

1、G1

1、G1内存模型

2、基础概念

3、G1特点:

4、CMS日志分析

5、G1日志分析

2、GC参数

2.1、GC常用参数

2.2、Parallel常用参数

2.3、CMS常用参数

2.4、G1常用参数


一、JVM Optimization

1、G1

G1官网说明:Garbage First Garbage Collector Tuning

The Garbage First Garbage Collector (G1 GC) is the low-pause, server-style generational 
garbage collector for Java HotSpot VM. The G1 GC uses concurrent and parallel phases 
to achieve its target pause time and to maintain good throughput. When G1 GC determines 
that a garbage collection is necessary, it collects the regions with the least live data 
first (garbage first).
G1是Java HotSpot VM的低暂停、服务器端应用的垃圾收集器。G1 GC使用并行和并行阶段来实现其目标暂停
时间并保持良好的吞吐量。当G1GC确定有必要进行垃圾收集时,它首先收集具有最少活动数据的区域
(垃圾优先)。G1是一种服务端应用使用的垃圾收集器,目标是用在多核、大内存的机器上,它在大多数情况下可以实现指定
的GC暂停时间,同时还能保持较高的吞吐量。

分而治之+分层模型

1、G1内存模型

humongous:/hjuːˈmʌŋɡəs/ 巨大的、庞大的

humongous object:超过单个region的50%

it collects the regions with the least live data first (garbage first).垃圾优先

        每个分区都可能是年轻代也可能是老年代,但是在同一时刻只能属于某个代。
        年轻代、幸存区、老年代这些概念还存在,成为逻辑上的概念,这样方便复用之前分代框架的逻辑。在物理上不需要连续,则带来了额外的好处——有的分区内垃圾对象特别多,有的分区内垃圾对象很少,G1会优先回收垃圾对象特别多的分区,这样可以花费较少的时间来回收这些分区的垃圾,这也就是G1名字的由来,即首先收集垃圾最多的分区。
        新生代其实并不是适用于这种算法的,依然是在新生代满了的时候,对整个新生代进行回收——整个新生代中的对象,要么被回收、要么晋升,至于新生代也采取分区机制的原因,则是因为这样跟老年代的策略统一,方便调整代的大小。
        G1还是一种带压缩的收集器,在回收老年代的分区时,是将存活的对象从一个分区拷贝到另一个可用分区,这个拷贝的过程就实现了局部的压缩。每个分区的大小从1M到32M不等,但是都是2的幂次方。

2、基础概念

1、Card Table

由于做YGC时,需要扫描整个OLD区(因为OLD区有可能有引用指向Y区),效率非常低,所以JVM设计了CardTable, 如果一个OLD区CardTable中有对象指向Y区,就将它设为Dirty,下次扫描时,只需要扫描Dirty Card

在结构上,Card Table用BitMap来实现。(Dirty:肮脏的,脏数据)

2、CSet = Collection Set
一组可被回收的分区的集合。
在CSet中存活的数据会在GC过程中被移动到另一个可用分区,CSet中的分区可以来自Eden空间、survivor空间、或者老年代。
CSet会占用不到整个堆空间的1%大小。

3、RSet = RememberedSet    (Remembered:记得)

在Region中有一块区域,记录了其他Region中的对象到本Region的引用
RSet的价值在于使得垃圾收集器不需要扫描整个堆找到谁引用了当前分区中的对象,只需要扫描RSet即可。

4、RSet与赋值的效率

由于RSet 的存在,那么每次给对象赋引用的时候,就得做一些额外的操作,指的是在RSet中做一些额外的记录(在GC中被称为写屏障),这个写屏障 不等于 内存屏障

5、GC何时触发

YGC:Eden空间不足、多线程并行执行

FGC:Old空间不足、System.gc()

6、G1是否分代?G1垃圾回收器会产生FGC吗?

G1是逻辑分代,物理不分代。会产生FGC,最后的对象分配不开了

7、如果G1产生FGC,你应该做什么?

    1.扩内存

    2. 提高CPU性能

    3. 降低MixedGC触发的阈值,让MixedGC提早发生(默认是45%)

8、G1中的MixedGC

    1.=CMS

    2.XX:InitiatingHeapOccupacyPercent  默认值45%,当O超过这个值时,启动MixedGC

9、MixedGC的过程

    1.初始标记 STW

    2.并发标记

SATB算法:
Snapshot At The Beginning
GC开始时,通过root tracing得到一个Snapshot
维持并发GC的正确性
如何做到并发GC的正确性:
三色标记算法:
白:对象没有标记,标记阶段结束后,会被回收
灰:对象标记了,但是他的Field还没有标记或标记完
黑:对象标记了,且他的Field也标记完成

漏标

    在remark过程中,黑色指向了白色,如果不对黑色重新扫描,则会漏标。会把白色D对象当做没有新引用指向从而回收掉。

    并发标记过程中,删除了所有从灰色到白色的引用,会产生漏标,此时白色对象应该被回收。

漏标是指,本来是live object,但是由于没有遍历到,被当成garbage回收掉了

产生漏标:

    ①. 标记进行时增加了一个黑到白的引用,如果不重新对黑色进行处理,则会漏标
    ②. 标记进行时删除了灰对象到白对象的引用,那么这个白对象有可能被漏标

打破上述两个条件之一即可,解决漏标问题

    ①. incremental update -- 增量更新,关注引用的增加,把黑色重新标记为灰色,下次重新扫描属性,CMS使用。

    ②. SATB snapshot at the beginning – 关注引用的删除,当B->D消失时,要把这个引用推到GC的堆栈,保证D还能被GC扫描到,G1使用。

    3.最终标记 STW (重新标记)

    4.筛选回收 STW (并行)

10、为什么G1用SATB?

灰色 → 白色 引用消失时,如果没有黑色指向白色,引用会被push到堆栈。
下次扫描时拿到这个引用,由于有RSet的存在,不需要扫描整个堆去查找指向白色的引用,效率比较高。SATB 配合 RSet ,浑然天成

11、G1的Full GC

java 10以前是串行FullGC,之后是并行FullGC

12、G1新老年代比例

5%-60%,一般不用手工指定,也不要手工指定,因为这是G1预测停顿时间的基准

13、每个Region有多大 

取值1 2 4 8 16 32   即2的幂次方

手工指定 -XX:G1HeapRegionSize

3、G1特点:

  1. 并发收集
  2. 压缩空闲空间不会延长GC的暂停时间
  3. 更易预测的GC暂停时间
  4. 适用不需要实现很高的吞吐量的场景

4、CMS日志分析

JVM Optimization Learning(四)

中的JVM Optimization Case环境继续使用此环境

[root@localhost java]# java -Xms20M -Xmx20M -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC com.lwz.jvm.T15_FullGC_Problem01
[GC (Allocation Failure) [ParNew: 5504K->640K(6144K), 0.0124495 secs] 5504K->1049K(19840K), 0.0126009 secs] [Times: user=0.01 sys=0.01, real=0.02 secs]
[GC (Allocation Failure) [ParNew: 6144K->640K(6144K), 0.0273421 secs] 6553K->2858K(19840K), 0.0274255 secs] [Times: user=0.08 sys=0.00, real=0.02 secs]
[GC (Allocation Failure) [ParNew: 6144K->640K(6144K), 0.0169154 secs] 8362K->6127K(19840K), 0.0171555 secs] [Times: user=0.05 sys=0.00, real=0.02 secs]
[GC (Allocation Failure) [ParNew: 6144K->640K(6144K), 0.0139854 secs] 11631K->9628K(19840K), 0.0140778 secs] [Times: user=0.05 sys=0.00, real=0.02 secs]
[GC (CMS Initial Mark) [1 CMS-initial-mark: 8988K(13696K)] 9628K(19840K), 0.0014297 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.030/0.030 secs] [Times: user=0.04 sys=0.00, real=0.03 secs]
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (CMS Final Remark) [YG occupancy: 1274 K (6144 K)][Rescan (parallel) , 0.0012268 secs][weak refs processing, 0.0000665 secs][class unloading, 0.0014624 secs][scrub symbol table, 0.0007199 secs][scrub string table, 0.0003808 secs][1 CMS-remark: 8988K(13696K)] 10262K(19840K), 0.0041094 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.015/0.015 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (CMS Initial Mark) [1 CMS-initial-mark: 8926K(13696K)] 10982K(19840K), 0.0012949 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.018/0.018 secs] [Times: user=0.02 sys=0.00, real=0.02 secs]
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.002/0.002 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (CMS Final Remark) [YG occupancy: 2056 K (6144 K)][Rescan (parallel) , 0.0006445 secs][weak refs processing, 0.0000152 secs][class unloading, 0.0008104 secs][scrub symbol table, 0.0005612 secs][scrub string table, 0.0002756 secs][1 CMS-remark: 8926K(13696K)] 10982K(19840K), 0.0024193 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.005/0.005 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (CMS Initial Mark) [1 CMS-initial-mark: 8926K(13696K)] 11454K(19840K), 0.0018331 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.031/0.031 secs] [Times: user=0.04 sys=0.00, real=0.03 secs]
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.004/0.004 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
[GC (CMS Final Remark) [YG occupancy: 2528 K (6144 K)][Rescan (parallel) , 0.0086513 secs][weak refs processing, 0.0000225 secs][class unloading, 0.0009794 secs][scrub symbol table, 0.0005974 secs][scrub string table, 0.0002462 secs][1 CMS-remark: 8926K(13696K)] 11454K(19840K), 0.0106071 secs] [Times: user=0.04 sys=0.00, real=0.01 secs]
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.005/0.005 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (CMS Initial Mark) [1 CMS-initial-mark: 8926K(13696K)] 11791K(19840K), 0.0017124 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.028/0.028 secs] [Times: user=0.03 sys=0.00, real=0.02 secs]
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.002/0.002 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
[CMS-concurrent-abortable-preclean-start]CMS: abort preclean due to time [CMS-concurrent-abortable-preclean: 1.068/5.088 secs] [Times: user=1.51 sys=0.00, real=5.08 secs]
[GC (CMS Final Remark) [YG occupancy: 4373 K (6144 K)][Rescan (parallel) , 0.0016615 secs][weak refs processing, 0.0000167 secs][class unloading, 0.0007608 secs][scrub symbol table, 0.0005483 secs][scrub string table, 0.0002508 secs][1 CMS-remark: 8926K(13696K)] 13299K(19840K), 0.0033322 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.007/0.007 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.012/0.012 secs] [Times: user=0.01 sys=0.00, real=0.02 secs]
[GC (CMS Initial Mark) [1 CMS-initial-mark: 8926K(13696K)] 13771K(19840K), 0.0030760 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.027/0.027 secs] [Times: user=0.03 sys=0.00, real=0.03 secs]
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.005/0.005 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[CMS-concurrent-abortable-preclean-start]
[CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (CMS Final Remark) [YG occupancy: 4845 K (6144 K)][Rescan (parallel) , 0.0024014 secs][weak refs processing, 0.0000203 secs][class unloading, 0.0010572 secs][scrub symbol table, 0.0007175 secs][scrub string table, 0.0003684 secs][1 CMS-remark: 8926K(13696K)] 13771K(19840K), 0.0046857 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.007/0.007 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (CMS Initial Mark) [1 CMS-initial-mark: 8926K(13696K)] 14998K(19840K), 0.0048182 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.021/0.021 secs] [Times: user=0.03 sys=0.00, real=0.02 secs]
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.004/0.004 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
[CMS-concurrent-abortable-preclean-start]
[CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (CMS Final Remark) [YG occupancy: 6072 K (6144 K)][Rescan (parallel) , 0.0032505 secs][weak refs processing, 0.0000216 secs][class unloading, 0.0010294 secs][scrub symbol table, 0.0006718 secs][scrub string table, 0.0003728 secs][1 CMS-remark: 8926K(13696K)] 14998K(19840K), 0.0055128 secs] [Times: user=0.02 sys=0.00, real=0.00 secs]
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.011/0.011 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [ParNew: 6144K->640K(6144K), 0.0149299 secs] 14864K->12924K(19840K), 0.0150074 secs] [Times: user=0.06 sys=0.00, real=0.02 secs]
[GC (CMS Initial Mark) [1 CMS-initial-mark: 12284K(13696K)] 13014K(19840K), 0.0008257 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.026/0.026 secs] [Times: user=0.03 sys=0.00, real=0.02 secs]
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
[GC (CMS Final Remark) [YG occupancy: 1336 K (6144 K)][Rescan (parallel) , 0.0007401 secs][weak refs processing, 0.0000219 secs][class unloading, 0.0010162 secs][scrub symbol table, 0.0006404 secs][scrub string table, 0.0004188 secs][1 CMS-remark: 12284K(13696K)] 13621K(19840K), 0.0029844 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[CMS-concurrent-sweep-start]

ParNew年轻代:

[GC (Allocation Failure) [ParNew: 5504K->640K(6144K), 0.0124495 secs] 5504K->1049K(19840K), 0.0126009 secs] [Times: user=0.01 sys=0.01, real=0.02 secs]
ParNew:年轻代收集器
5504K->640K:收集前后的对比
(6144K):整个年轻代容量
5504K->1049K:整个堆的情况
(19840K):整个堆大小

CMS老年代回收日志---主要看1.频繁不频繁,2.花的时间长不长,是不是在我允许的范围之内

[GC (CMS Initial Mark) [1 CMS-initial-mark: 8988K(13696K)] 9628K(19840K), 0.0014297 secs][Times: user=0.00 sys=0.00, real=0.00 secs]//8988K(13696K) : 老年代使用(最大)//9628K(19840K) : 整个堆使用(最大)
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.030/0.030 secs] [Times: user=0.04 sys=0.00, real=0.03 secs]//这里的时间意义不大,因为是并发执行
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]//标记Card为Dirty,也称为Card Marking
[GC (CMS Final Remark) [YG occupancy: 1274 K (6144 K)][Rescan (parallel) , 0.0012268 secs]
[weak refs processing, 0.0000665 secs][class unloading, 0.0014624 secs][scrub symbol table,0.0007199 secs][scrub string table, 0.0003808 secs][1 CMS-remark: 8988K(13696K)]10262K(19840K), 0.0041094 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]//STW阶段,YG occupancy:年轻代占用及容量//[Rescan (parallel):STW下的存活对象标记//weak refs processing: 弱引用处理//class unloading: 卸载用不到的class//scrub symbol(string) table: //cleaning up symbol and string tables which hold class-level metadata and //internalized string respectively//CMS-remark: 8988K(13696K): 阶段过后的老年代占用及容量//10262K(19840K): 阶段过后的堆占用及容量
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.015/0.015 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]//标记已经完成,进行并发清理
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]//重置内部结构,为下次GC做准备

5、G1日志分析

JVM Optimization Learning(四) ---JVM Optimization Case环境继续使用此环境

[root@localhost java]# java -Xms20M -Xmx20M -XX:+PrintGCDetails -XX:+UseG1GC com.lwz.jvm.T15_FullGC_Problem01
[GC pause (G1 Evacuation Pause) (young), 0.0091218 secs][Parallel Time: 7.8 ms, GC Workers: 4][GC Worker Start (ms): Min: 7838.5, Avg: 7842.2, Max: 7846.0, Diff: 7.5][Ext Root Scanning (ms): Min: 0.0, Avg: 1.0, Max: 2.0, Diff: 2.0, Sum: 4.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.1, Max: 0.2, Diff: 0.2, Sum: 0.2][Object Copy (ms): Min: 0.0, Avg: 2.5, Max: 5.2, Diff: 5.2, Sum: 10.0][Termination (ms): Min: 0.0, Avg: 0.2, Max: 0.4, Diff: 0.4, Sum: 1.0][Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 4][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.1][GC Worker Total (ms): Min: 0.1, Avg: 3.9, Max: 7.6, Diff: 7.6, Sum: 15.5][GC Worker End (ms): Min: 7846.1, Avg: 7846.1, Max: 7846.1, Diff: 0.1][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.3 ms][Other: 1.0 ms][Choose CSet: 0.0 ms][Ref Proc: 0.5 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.3 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 12.0M(12.0M)->0.0B(10.0M) Survivors: 0.0B->2048.0K Heap: 12.0M(20.0M)->1952.0K(20.0M)][Times: user=0.02 sys=0.01, real=0.01 secs]
[GC pause (G1 Evacuation Pause) (young), 0.0184956 secs][Parallel Time: 16.2 ms, GC Workers: 4][GC Worker Start (ms): Min: 31098.3, Avg: 31098.9, Max: 31099.7, Diff: 1.3][Ext Root Scanning (ms): Min: 0.4, Avg: 2.9, Max: 8.0, Diff: 7.6, Sum: 11.4][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.1, Max: 0.4, Diff: 0.4, Sum: 0.4][Object Copy (ms): Min: 7.5, Avg: 12.4, Max: 14.2, Diff: 6.7, Sum: 49.7][Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0][Termination Attempts: Min: 3, Avg: 4.2, Max: 8, Diff: 5, Sum: 17][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.1][GC Worker Total (ms): Min: 14.6, Avg: 15.4, Max: 15.9, Diff: 1.3, Sum: 61.7][GC Worker End (ms): Min: 31114.3, Avg: 31114.3, Max: 31114.3, Diff: 0.0][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.8 ms][Other: 1.4 ms][Choose CSet: 0.0 ms][Ref Proc: 0.6 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.6 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 10.0M(10.0M)->0.0B(7168.0K) Survivors: 2048.0K->2048.0K Heap: 11.9M(20.0M)->6817.5K(20.0M)][Times: user=0.05 sys=0.01, real=0.02 secs]
[GC pause (G1 Evacuation Pause) (young) (to-space exhausted), 0.0245234 secs][Parallel Time: 16.8 ms, GC Workers: 4][GC Worker Start (ms): Min: 53252.5, Avg: 53252.7, Max: 53252.9, Diff: 0.4][Ext Root Scanning (ms): Min: 0.5, Avg: 0.7, Max: 0.9, Diff: 0.4, Sum: 2.8][Update RS (ms): Min: 2.9, Avg: 3.0, Max: 3.3, Diff: 0.4, Sum: 12.0][Processed Buffers: Min: 12, Avg: 14.2, Max: 18, Diff: 6, Sum: 57][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.0, Diff: 0.0, Sum: 0.0][Object Copy (ms): Min: 12.1, Avg: 12.3, Max: 12.5, Diff: 0.5, Sum: 49.3][Termination (ms): Min: 0.0, Avg: 0.2, Max: 0.3, Diff: 0.3, Sum: 0.6][Termination Attempts: Min: 1, Avg: 1.2, Max: 2, Diff: 1, Sum: 5][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1][GC Worker Total (ms): Min: 16.1, Avg: 16.2, Max: 16.5, Diff: 0.4, Sum: 65.0][GC Worker End (ms): Min: 53269.0, Avg: 53269.0, Max: 53269.0, Diff: 0.0][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.7 ms][Other: 7.0 ms][Evacuation Failure: 5.8 ms][Choose CSet: 0.0 ms][Ref Proc: 0.4 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.6 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 7168.0K(7168.0K)->0.0B(1024.0K) Survivors: 2048.0K->2048.0K Heap: 13.7M(20.0M)->19.0M(20.0M)][Times: user=0.08 sys=0.00, real=0.02 secs]
[GC pause (G1 Evacuation Pause) (young) (initial-mark) (to-space exhausted), 0.0435448 secs][Parallel Time: 35.5 ms, GC Workers: 4][GC Worker Start (ms): Min: 56073.6, Avg: 56073.8, Max: 56073.9, Diff: 0.3][Ext Root Scanning (ms): Min: 0.5, Avg: 0.6, Max: 0.8, Diff: 0.3, Sum: 2.5][Update RS (ms): Min: 0.0, Avg: 3.5, Max: 14.1, Diff: 14.1, Sum: 14.1][Processed Buffers: Min: 0, Avg: 14.2, Max: 57, Diff: 57, Sum: 57][Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.1][Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0][Object Copy (ms): Min: 20.1, Avg: 30.9, Max: 34.6, Diff: 14.5, Sum: 123.6][Termination (ms): Min: 0.0, Avg: 0.2, Max: 0.4, Diff: 0.4, Sum: 0.7][Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 4][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0][GC Worker Total (ms): Min: 35.1, Avg: 35.2, Max: 35.4, Diff: 0.3, Sum: 141.0][GC Worker End (ms): Min: 56109.0, Avg: 56109.0, Max: 56109.0, Diff: 0.0][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.6 ms][Other: 7.4 ms][Evacuation Failure: 6.4 ms][Choose CSet: 0.0 ms][Ref Proc: 0.4 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.5 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 1024.0K(1024.0K)->0.0B(1024.0K) Survivors: 2048.0K->0.0B Heap: 20.0M(20.0M)->20.0M(20.0M)][Times: user=0.07 sys=0.00, real=0.04 secs]
[GC concurrent-root-region-scan-start]
[GC concurrent-root-region-scan-end, 0.0001056 secs]
[GC concurrent-mark-start]
[Full GC (Allocation Failure)  20M->11M(20M), 0.0384932 secs][Eden: 0.0B(1024.0K)->0.0B(3072.0K) Survivors: 0.0B->0.0B Heap: 20.0M(20.0M)->11.1M(20.0M)], [Metaspace: 3879K->3873K(1056768K)][Times: user=0.05 sys=0.00, real=0.04 secs]
[GC concurrent-mark-abort]
[GC pause (G1 Evacuation Pause) (young), 0.0100011 secs][Parallel Time: 8.4 ms, GC Workers: 4][GC Worker Start (ms): Min: 65691.5, Avg: 65691.7, Max: 65691.8, Diff: 0.3][Ext Root Scanning (ms): Min: 0.4, Avg: 0.6, Max: 0.7, Diff: 0.3, Sum: 2.2][Update RS (ms): Min: 3.9, Avg: 4.0, Max: 4.1, Diff: 0.2, Sum: 16.0][Processed Buffers: Min: 13, Avg: 14.8, Max: 17, Diff: 4, Sum: 59][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.0, Diff: 0.0, Sum: 0.0][Object Copy (ms): Min: 3.4, Avg: 3.5, Max: 3.6, Diff: 0.2, Sum: 13.9][Termination (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 0.5][Termination Attempts: Min: 18, Avg: 22.8, Max: 26, Diff: 8, Sum: 91][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1][GC Worker Total (ms): Min: 8.0, Avg: 8.2, Max: 8.4, Diff: 0.3, Sum: 32.8][GC Worker End (ms): Min: 65699.8, Avg: 65699.8, Max: 65699.8, Diff: 0.0][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.5 ms][Other: 1.0 ms][Choose CSet: 0.0 ms][Ref Proc: 0.5 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.4 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 3072.0K(3072.0K)->0.0B(1024.0K) Survivors: 0.0B->1024.0K Heap: 14.1M(20.0M)->13.6M(20.0M)][Times: user=0.04 sys=0.00, real=0.01 secs]
[GC pause (G1 Evacuation Pause) (young) (initial-mark), 0.0105135 secs][Parallel Time: 8.5 ms, GC Workers: 4][GC Worker Start (ms): Min: 69872.2, Avg: 69872.4, Max: 69872.6, Diff: 0.4][Ext Root Scanning (ms): Min: 0.5, Avg: 0.7, Max: 0.9, Diff: 0.4, Sum: 2.7][Update RS (ms): Min: 4.1, Avg: 4.2, Max: 4.3, Diff: 0.2, Sum: 16.7][Processed Buffers: Min: 12, Avg: 14.8, Max: 17, Diff: 5, Sum: 59][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.0, Diff: 0.0, Sum: 0.0][Object Copy (ms): Min: 3.1, Avg: 3.2, Max: 3.3, Diff: 0.2, Sum: 12.8][Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.2][Termination Attempts: Min: 11, Avg: 14.2, Max: 16, Diff: 5, Sum: 57][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1][GC Worker Total (ms): Min: 7.9, Avg: 8.1, Max: 8.3, Diff: 0.4, Sum: 32.6][GC Worker End (ms): Min: 69880.6, Avg: 69880.6, Max: 69880.6, Diff: 0.0][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.7 ms][Other: 1.4 ms][Choose CSet: 0.0 ms][Ref Proc: 0.7 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.5 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 1024.0K(1024.0K)->0.0B(1024.0K) Survivors: 1024.0K->1024.0K Heap: 14.6M(20.0M)->15.4M(20.0M)][Times: user=0.03 sys=0.00, real=0.01 secs]
[GC concurrent-root-region-scan-start]
[GC concurrent-root-region-scan-end, 0.0029410 secs]
[GC concurrent-mark-start]
[GC concurrent-mark-end, 0.0485784 secs]
[GC remark [Finalize Marking, 0.0005557 secs] [GC ref-proc, 0.0003018 secs] [Unloading, 0.0014276 secs], 0.0029364 secs][Times: user=0.01 sys=0.00, real=0.00 secs]
[GC cleanup 15M->15M(20M), 0.0013613 secs][Times: user=0.00 sys=0.00, real=0.00 secs]
[GC pause (G1 Evacuation Pause) (young), 0.0114531 secs][Parallel Time: 9.6 ms, GC Workers: 4][GC Worker Start (ms): Min: 73775.8, Avg: 73775.9, Max: 73776.1, Diff: 0.3][Ext Root Scanning (ms): Min: 0.4, Avg: 0.5, Max: 0.7, Diff: 0.3, Sum: 2.2][Update RS (ms): Min: 5.7, Avg: 5.8, Max: 5.9, Diff: 0.3, Sum: 23.0][Processed Buffers: Min: 15, Avg: 15.2, Max: 16, Diff: 1, Sum: 61][Scan RS (ms): Min: 0.0, Avg: 0.2, Max: 0.3, Diff: 0.2, Sum: 0.7][Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0][Object Copy (ms): Min: 2.7, Avg: 2.8, Max: 2.8, Diff: 0.1, Sum: 11.1][Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0][Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 4][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1][GC Worker Total (ms): Min: 9.1, Avg: 9.3, Max: 9.4, Diff: 0.3, Sum: 37.0][GC Worker End (ms): Min: 73785.2, Avg: 73785.2, Max: 73785.2, Diff: 0.0][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.6 ms][Other: 1.3 ms][Choose CSet: 0.0 ms][Ref Proc: 0.6 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.4 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 1024.0K(1024.0K)->0.0B(1024.0K) Survivors: 1024.0K->1024.0K Heap: 16.4M(20.0M)->16.7M(20.0M)][Times: user=0.04 sys=0.00, real=0.01 secs]
[GC pause (G1 Evacuation Pause) (mixed) (to-space exhausted), 0.0406284 secs][Parallel Time: 34.3 ms, GC Workers: 4][GC Worker Start (ms): Min: 77404.1, Avg: 77404.4, Max: 77404.7, Diff: 0.6][Ext Root Scanning (ms): Min: 0.3, Avg: 0.6, Max: 0.9, Diff: 0.6, Sum: 2.2][Update RS (ms): Min: 4.1, Avg: 4.2, Max: 4.2, Diff: 0.1, Sum: 16.8][Processed Buffers: Min: 13, Avg: 15.2, Max: 18, Diff: 5, Sum: 61][Scan RS (ms): Min: 0.0, Avg: 0.1, Max: 0.4, Diff: 0.4, Sum: 0.5][Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0][Object Copy (ms): Min: 28.7, Avg: 29.0, Max: 29.1, Diff: 0.4, Sum: 115.9][Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0][Termination Attempts: Min: 1, Avg: 1.2, Max: 2, Diff: 1, Sum: 5][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1][GC Worker Total (ms): Min: 33.6, Avg: 33.9, Max: 34.2, Diff: 0.6, Sum: 135.4][GC Worker End (ms): Min: 77438.3, Avg: 77438.3, Max: 77438.3, Diff: 0.0][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.5 ms][Other: 5.8 ms][Evacuation Failure: 4.3 ms][Choose CSet: 0.0 ms][Ref Proc: 0.7 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.7 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 1024.0K(1024.0K)->0.0B(1024.0K) Survivors: 1024.0K->1024.0K Heap: 17.7M(20.0M)->19.1M(20.0M)][Times: user=0.07 sys=0.00, real=0.04 secs]
[GC pause (G1 Evacuation Pause) (young) (to-space exhausted), 0.0146382 secs][Parallel Time: 11.7 ms, GC Workers: 4][GC Worker Start (ms): Min: 77445.6, Avg: 77445.8, Max: 77446.3, Diff: 0.7][Ext Root Scanning (ms): Min: 0.0, Avg: 0.4, Max: 0.6, Diff: 0.6, Sum: 1.6][Update RS (ms): Min: 0.0, Avg: 2.3, Max: 5.0, Diff: 5.0, Sum: 9.3][Processed Buffers: Min: 0, Avg: 65.5, Max: 156, Diff: 156, Sum: 262][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.0, Diff: 0.0, Sum: 0.0][Object Copy (ms): Min: 5.6, Avg: 8.3, Max: 10.6, Diff: 5.0, Sum: 33.1][Termination (ms): Min: 0.0, Avg: 0.1, Max: 0.3, Diff: 0.3, Sum: 0.5][Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 4][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0][GC Worker Total (ms): Min: 10.7, Avg: 11.2, Max: 11.4, Diff: 0.7, Sum: 44.6][GC Worker End (ms): Min: 77457.0, Avg: 77457.0, Max: 77457.0, Diff: 0.0][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.4 ms][Other: 2.6 ms][Evacuation Failure: 1.5 ms][Choose CSet: 0.0 ms][Ref Proc: 0.6 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.4 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 0.0B(1024.0K)->0.0B(1024.0K) Survivors: 1024.0K->0.0B Heap: 19.1M(20.0M)->19.1M(20.0M)][Times: user=0.02 sys=0.00, real=0.01 secs]

G1日志young     参照CMS日志查看

[GC pause (G1 Evacuation Pause) (young), 0.0091218 secs][Parallel Time: 7.8 ms, GC Workers: 4][GC Worker Start (ms): Min: 7838.5, Avg: 7842.2, Max: 7846.0, Diff: 7.5][Ext Root Scanning (ms): Min: 0.0, Avg: 1.0, Max: 2.0, Diff: 2.0, Sum: 4.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.1, Max: 0.2, Diff: 0.2, Sum: 0.2][Object Copy (ms): Min: 0.0, Avg: 2.5, Max: 5.2, Diff: 5.2, Sum: 10.0][Termination (ms): Min: 0.0, Avg: 0.2, Max: 0.4, Diff: 0.4, Sum: 1.0][Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 4][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.1][GC Worker Total (ms): Min: 0.1, Avg: 3.9, Max: 7.6, Diff: 7.6, Sum: 15.5][GC Worker End (ms): Min: 7846.1, Avg: 7846.1, Max: 7846.1, Diff: 0.1][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.3 ms]  //清理Card table[Other: 1.0 ms][Choose CSet: 0.0 ms][Ref Proc: 0.5 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.3 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 12.0M(12.0M)->0.0B(10.0M) Survivors: 0.0B->2048.0K Heap: 12.0M(20.0M)->1952.0K(20.0M)][Times: user=0.02 sys=0.01, real=0.01 secs]

G1日志mixedGC--混合回收

查看日志回收是否回收正常,没回收代表不正常

[GC pause (G1 Evacuation Pause) (young) (initial-mark) (to-space exhausted), 0.0435448 secs]
//young -> 年轻代 Evacuation(疏散,撤离)-> 复制存活对象 
//initial-mark 混合回收的阶段(mixedGC),这里是YGC混合老年代回收[Parallel Time: 35.5 ms, GC Workers: 4]  //4个GC线程[GC Worker Start (ms): Min: 56073.6, Avg: 56073.8, Max: 56073.9, Diff: 0.3][Ext Root Scanning (ms): Min: 0.5, Avg: 0.6, Max: 0.8, Diff: 0.3, Sum: 2.5][Update RS (ms): Min: 0.0, Avg: 3.5, Max: 14.1, Diff: 14.1, Sum: 14.1][Processed Buffers: Min: 0, Avg: 14.2, Max: 57, Diff: 57, Sum: 57][Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.1][Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0][Object Copy (ms): Min: 20.1, Avg: 30.9, Max: 34.6, Diff: 14.5, Sum: 123.6][Termination (ms): Min: 0.0, Avg: 0.2, Max: 0.4, Diff: 0.4, Sum: 0.7][Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 4][GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0][GC Worker Total (ms): Min: 35.1, Avg: 35.2, Max: 35.4, Diff: 0.3, Sum: 141.0][GC Worker End (ms): Min: 56109.0, Avg: 56109.0, Max: 56109.0, Diff: 0.0][Code Root Fixup: 0.0 ms][Code Root Purge: 0.0 ms][Clear CT: 0.6 ms]   //清理Card table[Other: 7.4 ms][Evacuation Failure: 6.4 ms][Choose CSet: 0.0 ms][Ref Proc: 0.4 ms][Ref Enq: 0.0 ms][Redirty Cards: 0.5 ms][Humongous Register: 0.0 ms][Humongous Reclaim: 0.0 ms][Free CSet: 0.0 ms][Eden: 1024.0K(1024.0K)->0.0B(1024.0K) Survivors: 2048.0K->0.0B 
Heap: 20.0M(20.0M)->20.0M(20.0M)][Times: user=0.07 sys=0.00, real=0.04 secs]
//以下是混合回收其他阶段
[GC concurrent-root-region-scan-start]
[GC concurrent-root-region-scan-end, 0.0001056 secs]
[GC concurrent-mark-start]
//无法evacuation,进行FGC
[Full GC (Allocation Failure)  20M->11M(20M), 0.0384932 secs][Eden: 0.0B(1024.0K)->0.0B(3072.0K) Survivors: 0.0B->0.0B 
Heap: 20.0M(20.0M)->11.1M(20.0M)], [Metaspace: 3879K->3873K(1056768K)][Times: user=0.05 sys=0.00, real=0.04 secs]
[GC concurrent-mark-abort]

2、GC参数

2.1、GC常用参数

-Xmn -Xms -Xmx -Xss
  年轻代 最小堆 最大堆 栈空间
-XX:+UseTLAB
  使用TLAB,默认打开
-XX:+PrintTLAB
  打印TLAB的使用情况
-XX:TLABSize
  设置TLAB大小
-XX:+DisableExplictGC
  System.gc()不管用 ,FGC
-XX:+PrintGC

  打印GC信息
-XX:+PrintGCDetails

  打印GC详细信息
-XX:+PrintHeapAtGC

  打印GC堆栈信息
-XX:+PrintGCTimeStamps

  打印发生GC系统信息
-XX:+PrintGCApplicationConcurrentTime (低)
  打印应用程序时间
-XX:+PrintGCApplicationStoppedTime (低)
  打印应用程序暂停时长
-XX:+PrintReferenceGC (重要性低)
  记录回收了多少种不同引用类型的引用
-verbose:class
  类加载详细过程
-XX:+PrintVMOptions

  打印JVM运行时参数
-XX:+PrintFlagsFinal  (需要会)

   查找JVM命令设置的最终值

[root@localhost ~]# java -XX:+PrintFlagsFinal -version | grep G1double G1ConcMarkStepDurationMillis              = 10.000000                                                                {product}uintx G1ConcRSHotCardLimit                      = 4                                                                        {product}uintx G1ConcRSLogCacheSize                      = 10                                                                       {product}intx G1ConcRefinementGreenZone                 = 0                                                                        {product}intx G1ConcRefinementRedZone                   = 0                                                                        {product}intx G1ConcRefinementServiceIntervalMillis     = 300                                                                      {product}uintx G1ConcRefinementThreads                   = 0                                                                        {product}intx G1ConcRefinementThresholdStep             = 0                                                                        {product}intx G1ConcRefinementYellowZone                = 0                                                                        {product}uintx G1ConfidencePercent                       = 50                                                                       {product}uintx G1HeapRegionSize                          = 0                                                                        {product}uintx G1HeapWastePercent                        = 5                                                                        {product}uintx G1MixedGCCountTarget                      = 8                                                                        {product}intx G1RSetRegionEntries                       = 0                                                                        {product}uintx G1RSetScanBlockSize                       = 64                                                                       {product}intx G1RSetSparseRegionEntries                 = 0                                                                        {product}intx G1RSetUpdatingPauseTimePercent            = 10                                                                       {product}intx G1RefProcDrainInterval                    = 10                                                                       {product}uintx G1ReservePercent                          = 10                                                                       {product}uintx G1SATBBufferEnqueueingThresholdPercent    = 60                                                                       {product}intx G1SATBBufferSize                          = 1024                                                                     {product}intx G1UpdateBufferSize                        = 256                                                                      {product}bool G1UseAdaptiveConcRefinement               = true                                                                     {product}bool UseG1GC                                   = false                                                                    {product}
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

-XX:+PrintFlagsInitial  (需要会)

   查找JVM命令初始化默认值

[root@localhost ~]# java -XX:+PrintFlagsInitial -version | grep CMSbool CMSAbortSemantics                         = false                               {product}uintx CMSAbortablePrecleanMinWorkPerIteration   = 100                                 {product}intx CMSAbortablePrecleanWaitMillis            = 100                                 {manageable}uintx CMSBitMapYieldQuantum                     = 10485760                            {product}uintx CMSBootstrapOccupancy                     = 50                                  {product}bool CMSClassUnloadingEnabled                  = true                                {product}uintx CMSClassUnloadingMaxInterval              = 0                                   {product}bool CMSCleanOnEnter                           = true                                {product}bool CMSCompactWhenClearAllSoftRefs            = true                                {product}uintx CMSConcMarkMultiple                       = 32                                  {product}bool CMSConcurrentMTEnabled                    = true                                {product}uintx CMSCoordinatorYieldSleepCount             = 10                                  {product}bool CMSDumpAtPromotionFailure                 = false                               {product}bool CMSEdenChunksRecordAlways                 = true                                {product}uintx CMSExpAvgFactor                           = 50                                  {product}bool CMSExtrapolateSweep                       = false                               {product}uintx CMSFullGCsBeforeCompaction                = 0                                   {product}uintx CMSIncrementalDutyCycle                   = 10                                  {product}uintx CMSIncrementalDutyCycleMin                = 0                                   {product}bool CMSIncrementalMode                        = false                               {product}uintx CMSIncrementalOffset                      = 0                                   {product}bool CMSIncrementalPacing                      = true                                {product}uintx CMSIncrementalSafetyFactor                = 10                                  {product}uintx CMSIndexedFreeListReplenish               = 4                                   {product}intx CMSInitiatingOccupancyFraction            = -1                                  {product}uintx CMSIsTooFullPercentage                    = 98                                  {product}double CMSLargeCoalSurplusPercent                = 0.950000                            {product}double CMSLargeSplitSurplusPercent               = 1.000000                            {product}bool CMSLoopWarn                               = false                               {product}uintx CMSMaxAbortablePrecleanLoops              = 0                                   {product}intx CMSMaxAbortablePrecleanTime               = 5000                                {product}uintx CMSOldPLABMax                             = 1024                                {product}uintx CMSOldPLABMin                             = 16                                  {product}uintx CMSOldPLABNumRefills                      = 4                                   {product}uintx CMSOldPLABReactivityFactor                = 2                                   {product}bool CMSOldPLABResizeQuicker                   = false                               {product}uintx CMSOldPLABToleranceFactor                 = 4                                   {product}bool CMSPLABRecordAlways                       = true                                {product}uintx CMSParPromoteBlocksToClaim                = 16                                  {product}bool CMSParallelInitialMarkEnabled             = true                                {product}bool CMSParallelRemarkEnabled                  = true                                {product}bool CMSParallelSurvivorRemarkEnabled          = true                                {product}uintx CMSPrecleanDenominator                    = 3                                   {product}uintx CMSPrecleanIter                           = 3                                   {product}uintx CMSPrecleanNumerator                      = 2                                   {product}bool CMSPrecleanRefLists1                      = true                                {product}bool CMSPrecleanRefLists2                      = false                               {product}bool CMSPrecleanSurvivors1                     = false                               {product}bool CMSPrecleanSurvivors2                     = true                                {product}uintx CMSPrecleanThreshold                      = 1000                                {product}bool CMSPrecleaningEnabled                     = true                                {product}bool CMSPrintChunksInDump                      = false                               {product}bool CMSPrintEdenSurvivorChunks                = false                               {product}bool CMSPrintObjectsInDump                     = false                               {product}uintx CMSRemarkVerifyVariant                    = 1                                   {product}bool CMSReplenishIntermediate                  = true                                {product}uintx CMSRescanMultiple                         = 32                                  {product}uintx CMSSamplingGrain                          = 16384                               {product}bool CMSScavengeBeforeRemark                   = false                               {product}uintx CMSScheduleRemarkEdenPenetration          = 50                                  {product}uintx CMSScheduleRemarkEdenSizeThreshold        = 2097152                             {product}uintx CMSScheduleRemarkSamplingRatio            = 5                                   {product}double CMSSmallCoalSurplusPercent                = 1.050000                            {product}double CMSSmallSplitSurplusPercent               = 1.100000                            {product}bool CMSSplitIndexedFreeListBlocks             = true                                {product}intx CMSTriggerInterval                        = -1                                  {manageable}uintx CMSTriggerRatio                           = 80                                  {product}intx CMSWaitDuration                           = 2000                                {manageable}uintx CMSWorkQueueDrainThreshold                = 10                                  {product}bool CMSYield                                  = true                                {product}uintx CMSYieldSleepCount                        = 0                                   {product}uintx CMSYoungGenPerWorker                      = 67108864                            {pd product}uintx CMS_FLSPadding                            = 1                                   {product}uintx CMS_FLSWeight                             = 75                                  {product}uintx CMS_SweepPadding                          = 1                                   {product}uintx CMS_SweepTimerThresholdMillis             = 10                                  {product}uintx CMS_SweepWeight                           = 75                                  {product}bool PrintCMSInitiationStatistics              = false                               {product}intx PrintCMSStatistics                        = 0                                   {product}bool UseCMSBestFit                             = true                                {product}bool UseCMSCollectionPassing                   = true                                {product}bool UseCMSCompactAtFullCollection             = true                                {product}bool UseCMSInitiatingOccupancyOnly             = false                               {product}
[root@localhost ~]#

-Xloggc:opt/log/gc.log
-XX:MaxTenuringThreshold
  GC升代年龄,最大值15
锁自旋次数 -XX:PreBlockSpin 热点代码检测参数-XX:CompileThreshold 逃逸分析 标量替换 
不建议设置

2.2、Parallel常用参数

-XX:SurvivorRatio
-XX:PreTenureSizeThreshold
  大对象到底多大
-XX:MaxTenuringThreshold

  GC升代年龄,最大值15
-XX:+ParallelGCThreads
  并行收集器的线程数,同样适用于CMS,一般设为和CPU核数相同
-XX:+UseAdaptiveSizePolicy
  自动选择各区大小比例

2.3、CMS常用参数

-XX:+UseConcMarkSweepGC

  启动CMS垃圾回收器
-XX:ParallelCMSThreads
  CMS线程数量
-XX:CMSInitiatingOccupancyFraction
  使用多少比例的老年代后开始CMS收集,默认是68%(近似值),如果频繁发生SerialOld卡顿,应该调小,(频繁CMS回收)

怎么解决CMS回收器,浮动垃圾和碎片化的问题?
-XX:+UseCMSCompactAtFullCollection
  在FGC时进行压缩
-XX:CMSFullGCsBeforeCompaction
  多少次FGC之后进行压缩

-XX:+CMSClassUnloadingEnabled

  回收不用的class
-XX:CMSInitiatingPermOccupancyFraction
  达到什么比例时进行Perm回收
GCTimeRatio
  设置GC时间占用程序运行时间的百分比,是一个建议时间
-XX:MaxGCPauseMillis
  停顿时间,是一个建议时间,GC会尝试用各种手段达到这个时间,比如减小年轻代

2.4、G1常用参数

-XX:+UseG1GC

  启动G1GC
-XX:MaxGCPauseMillis
  建议值,G1会尝试调整Young区的块数来达到这个值
-XX:GCPauseIntervalMillis
  GC的间隔时间
-XX:+G1HeapRegionSize
  设置分区大小,建议逐渐增大该值,1 2 4 8 16 32。
  随着size增加,垃圾的存活时间更长,GC间隔更长,但每次GC的时间也会更长
  ZGC做了改进(动态区块大小)
G1NewSizePercent
  新生代最小比例,默认为5%
G1MaxNewSizePercent
  新生代最大比例,默认为60%
GCTimeRatio
  GC时间建议比例,G1会根据这个值调整堆空间
ConcGCThreads
  线程数量
InitiatingHeapOccupancyPercent
  启动G1的堆空间占用比例

JVM Optimization Learning(四)

不断学习才能不断提高!
生如蝼蚁,当立鸿鹄之志,命比纸薄,应有不屈之心。
乾坤未定,你我皆是黑马,若乾坤已定,谁敢说我不能逆转乾坤?
努力吧,机会永远是留给那些有准备的人,否则,机会来了,没有实力,只能眼睁睁地看着机会溜走。

http://www.tj-hxxt.cn/news/78681.html

相关文章:

  • 好素材网站猪肉价格最新消息
  • 做初中试卷的网站如何优化网站推广
  • 深圳服装网站建设长春网络优化最好的公司
  • 东莞专业微网站建设价格低苏州seo服务热线
  • 厦门过路费网站韶关疫情最新消息
  • 个人注册的网站可以做公司宣传用吗北京seo运营推广
  • 网站做推广的团队网络推广费用高吗
  • 京东优惠券网站建设郑州网络推广大包
  • 昆明做网站词排名优化百度号码查询平台
  • 电子口岸网站做资料库郑州免费做网站
  • 做网站建设销售员准备什么如何进行搜索引擎优化?
  • 如何用爬虫做网站监控快照网站
  • 网站开发使用架构seo网站推广有哪些
  • 怎么做电影网站页面的seo是什么字
  • 郑州 互联网 公司网站百度关键词优化快速排名软件
  • h5响应式网站源码互联网营销师证书是国家认可的吗
  • 网站管理员登陆后缀百度推广营销页
  • 怎么学建网站广告多的网站
  • 一个网站做多少关键词国内永久免费云服务器
  • 珠海企业集团网站建设国内最新新闻
  • 制作网站报价单关键词优化快速排名
  • html嵌入网站seo策略主要包括
  • 苹果直播软件下载网站信息流广告投放工作内容
  • 网站被攻击了怎么办广东疫情防控措施
  • 中山住房和建设局工程交易网站网络营销题库案例题
  • 网站管理入口怎么给自己的公司建立网站
  • 宝鸡微网站建设武汉seo创造者
  • 网站播放器源码市场营销专业
  • 宠物网站首页模板怎么快速排名
  • 网站备案有哪些资料如何用手机制作网站