Java教程

「是时候升级java11了」虚拟机Jvm参数设置

本文主要是介绍「是时候升级java11了」虚拟机Jvm参数设置,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

专栏目录

  1. 是时候升级java11了-01-jdk11优势和jdk选择
  2. 是时候升级java11了-02-升级jdk11踩坑记
  3. 是时候升级java11了-03虚拟机Jvm参数设置
  4. 是时候升级java11了-04微服务内http2通信之http2 Clear Text(h2c)
  5. 是时候升级java11了-05微服务内h2c通信的阻碍和问题解决

前言

紧接前2篇文章,我们今天来聊聊升级 Java11 之后的一写 Jvm 参数变化。Java11 删除掉了 cms 垃圾回收器,如果你升级到了 Java11 但是 Jvm 参数仍然使用 cms 垃圾回收器参数时控制台会报错,甚至会启动失败。

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Unrecognized VM option 'ParallelCMSThreads=2'
Did you mean 'ParallelGCThreads=<value>'? Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
复制代码

JAVA11 JVM 启动参数

G1GC 配置项:

Option and Default Value Description
-XX:+UseG1GC Use the Garbage First (G1) Collector
-XX:MaxGCPauseMillis=n Sets a target for the maximum GC pause time. This is a soft goal, and the JVM will make its best effort to achieve it.
-XX:InitiatingHeapOccupancyPercent=n Percentage of the (entire) heap occupancy to start a concurrent GC cycle. It is used by GCs that trigger a concurrent GC cycle based on the occupancy of the entire heap, not just one of the generations (e.g., G1). A value of 0 denotes 'do constant GC cycles'. The default value is 45.
-XX:NewRatio=n Ratio of old/new generation sizes. The default value is 2.
-XX:SurvivorRatio=n Ratio of eden/survivor space size. The default value is 8.
-XX:MaxTenuringThreshold=n Maximum value for tenuring threshold. The default value is 15.
-XX:ParallelGCThreads=n Sets the number of threads used during parallel phases of the garbage collectors. The default value varies with the platform on which the JVM is running.
-XX:ConcGCThreads=n Number of threads concurrent garbage collectors will use. The default value varies with the platform on which the JVM is running.
-XX:G1ReservePercent=n Sets the amount of heap that is reserved as a false ceiling to reduce the possibility of promotion failure. The default value is 10.
-XX:G1HeapRegionSize=n With G1 the Java heap is subdivided into uniformly sized regions. This sets the size of the individual sub-divisions. The default value of this parameter is determined ergonomically based upon heap size. The minimum value is 1Mb and the maximum value is 32Mb.

G1GC log 配置详细说明:

G1GC -Xlog:gc Log messages with gc tag using info level to stdout, with default decorations.
G1GC -Xlog:gc,safepoint Log messages with either gc or safepoint tags (exclusive), both using 'info' level, to stdout, with default decorations.
G1GC -Xlog:gc+ref=debug Log messages with both gc and ref tags, using debug level, to stdout, with default decorations.
G1GC -Xlog:gc=debug:file=gc.txt:none Log messages with gc tag using debug lev
这篇关于「是时候升级java11了」虚拟机Jvm参数设置的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!