【JVM 2】HotSpot VM GC 的种类,kalilinux教程推荐

2021/12/20 7:23:16

本文主要是介绍【JVM 2】HotSpot VM GC 的种类,kalilinux教程推荐,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

二、CMS GC Incremental mode

=============================

当要使用 concurrent low pause collector时,在java的opt里加上 -XX:+UseConcMarkSweepGC。concurrent low pause collector还有一种为CPU少的机器准备的模式,叫Incremental mode。这种模式使用一个CPU来在程序运行的过程中GC,只用很少的时间暂停程序,检查对象存活。

在Incremental mode里,每个收集过程中,会暂停两次,第二次略长。第一次用来,简单从root查询存活对象。第二次用来,详细检查存活对象。整个过程如下:

  • stop all application threads; do the initial mark; resume all application threads(第一次暂停,初始话标记)

  • do the concurrent mark (uses one procesor for the concurrent work)(运行是标记)

  • do the concurrent pre-clean (uses one processor for the concurrent work)(准备清理)

  • stop all application threads; do the remark; resume all application threads(第二次暂停,标记,检查)

  • do the concurrent sweep (uses one processor for the concurrent work)(运行过程中清理)

  • do the concurrent reset (uses one processor for the concurrent work)(复原)

当要使用Incremental mode时,需要使用以下几个变量:

-XX:+CMSIncrementalMode default: disabled 启动i-CMS模式(must with -XX:+UseConcMarkSweepGC)

-XX:+CMSIncrementalPacing default: disabled 提供自动校正功能

-XX:CMSIncrementalDutyCycle= default: 50 启动CMS的上线

-XX:CMSIncrementalDutyCycleMin= default: 10 启动CMS的下线

-XX:CMSIncrementalSafetyFactor= default: 10 用来计算循环次数

-XX:CMSIncrementalOffset= default: 0 最小循环次数(This is the percentage (0-100) by which the incremental mode duty cycle is shifted to the right within the period between minor collections.)

-XX:CMSExpAvgFactor= default: 25 提供一个指导收集数

SUN推荐的使用参数是:

-XX:+UseConcMarkSweepGC \

-XX:+CMSIncrementalMode \

-XX:+CMSIncrementalPacing \

-XX:CMSIncrementalDutyCycleMin=0 \

-XX:CMSIncrementalDutyCycle=10 \

《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》

【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享

XX:+PrintGC Details \

-XX:+PrintGCTimeStamps \

-XX:-TraceClassUnloading

注:如果使用throughput collector和concurrent low pause collector,这两种垃圾收集器,需要适当的挺高内存大小,以为多线程做准备。

三、如何选择collector

===================

app运行在单处理器机器上且没有pause time的要求,让vm选择单线程收集器serial collector。

重点考虑peak application performance(高性能),没有pause time太严格要求,选择并行收集器_parallel collector。_

重点考虑response time,pause time要小,选择并发收集器_concurrent collector。_

往期精彩内容:

Java知识体系总结(2021版)



这篇关于【JVM 2】HotSpot VM GC 的种类,kalilinux教程推荐的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程