JVM 运行时参数

面试题

JVM的参数,你知道的说一下 (百度)

说说你知道的几种主要的JVM参数(京东)

JVM调优调的哪些参数?在哪里写这些参数? (亚信)

内存调优参数都有什么?(顺丰)

JVM调优调的哪些参数?问这样有什么好处?在哪里写这些参数(浪潮)

JVM参数选项类型

官网说明:++https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html++

类型一:标准参数选项

特点:

比较稳定,后续版本基本不会变化;以-开头

各种选项:

运行java或者java -help可以看到所有的标准选项

-d32 使用 32 位数据模型 (如果可用)

-d64 使用 64 位数据模型 (如果可用)

-server 选择 "server" VM

默认 VM 是 server.

-cp <目录和 zip/jar 文件的类搜索路径>

-classpath <目录和 zip/jar 文件的类搜索路径>

用 ; 分隔的目录, JAR 档案

和 ZIP 档案列表, 用于搜索类文件。

-D<名称>=<值>

设置系统属性

-verbose:[class|gc|jni]

启用详细输出

-version 输出产品版本并退出

-version:<值>

警告: 此功能已过时, 将在

未来发行版中删除。

需要指定的版本才能运行

-showversion 输出产品版本并继续

-jre-restrict-search | -no-jre-restrict-search

警告: 此功能已过时, 将在

未来发行版中删除。

在版本搜索中包括/排除用户专用 JRE

-? -help 输出此帮助消息

-X 输出非标准选项的帮助

-ea[:<packagename>...|:<classname>]

-enableassertions[:<packagename>...|:<classname>]

按指定的粒度启用断言

-da[:<packagename>...|:<classname>]

-disableassertions[:<packagename>...|:<classname>]

禁用具有指定粒度的断言

-esa | -enablesystemassertions

启用系统断言

-dsa | -disablesystemassertions

禁用系统断言

-agentlib:<libname>[=<选项>]

加载本机代理库 <libname>, 例如 -agentlib:hprof

另请参阅 -agentlib:jdwp=help 和 -agentlib:hprof=help

-agentpath:<pathname>[=<选项>]

按完整路径名加载本机代理库

-javaagent:<jarpath>[=<选项>]

加载 Java 编程语言代理, 请参阅 java.lang.instrument

-splash:<imagepath>

使用指定的图像显示启动屏幕

有关详细信息, 请参阅:Java SE - Documentation

补充内容:-server与-client

Hotspot JVM有两种模式,分别是server和client,分别通过-server和-client模式设置

在32位Windows系统上,默认使用Client类型的JVM。要想使用Server模式,则机器配置至少有2个以上的CPU和2G以上的物理内存。 client模式适用于对内存要求较小的桌面应用程序,默认使用Serial串行垃圾收集器。

64位机器上只支持server模式的JVM,适用于需要大内存的应用程序,默认使用并行垃圾收集器。

关于server和client的官网介绍为:https://docs.oracle.com/javase/8/docs/technotes/guides/vm/server-class.html

类型二:-X参数选项

特点

非标准化参数;功能还是比较稳定的。但官方说后续版本可能会变更;以-X开头

各种选项

-Xmixed 混合模式执行 (默认)

-Xint 仅解释模式执行

-Xcomp 仅采用即时编译器模式

-Xbootclasspath:<用 ; 分隔的目录和 zip/jar 文件>

设置搜索路径以引导类和资源

-Xbootclasspath/a:<用 ; 分隔的目录和 zip/jar 文件>

附加在引导类路径末尾

-Xbootclasspath/p:<用 ; 分隔的目录和 zip/jar 文件>

置于引导类路径之前

-Xdiag 显示附加诊断消息

-Xnoclassgc 禁用类垃圾收集

-Xincgc 启用增量垃圾收集

-Xloggc:<file> 将 GC 状态记录在文件中 (带时间戳)

-Xbatch 禁用后台编译

-Xms<size> 设置初始 Java 堆大小

-Xmx<size> 设置最大 Java 堆大小

-Xss<size> 设置 Java 线程堆栈大小

-Xprof 输出 cpu 配置文件数据

-Xfuture 启用最严格的检查, 预期将来的默认值

-Xrs 减少 Java/VM 对操作系统信号的使用 (请参阅文档)

-Xcheck:jni 对 JNI 函数执行其他检查

-Xshare:off 不尝试使用共享类数据

-Xshare:auto 在可能的情况下使用共享类数据 (默认)

-Xshare:on 要求使用共享类数据, 否则将失败。

-XshowSettings 显示所有设置并继续

-XshowSettings:all 显示所有设置并继续

-XshowSettings:vm 显示所有与 vm 相关的设置并继续

-XshowSettings:properties 显示所有属性设置并继续

-XshowSettings:locale 显示所有与区域设置相关的设置并继续

-X 选项是非标准选项, 如有更改, 恕不另行通知。

JVM的JIT编译模式相关的选项

-Xint

禁用JIT,所有字节码都被解释执行,这个模式的速度最慢的

-Xcomp

所有字节码第一次使用就都被编译成本地代码,然后再执行

-Xmixed

混合模式,默认模式,让JIT根据程序运行的情况,有选择地将某些代码编译成本地代码

特别地

-Xmx -Xms -Xss属于XX参数?

-Xms<size>

设置初始Java堆大小,等价于-XX:InitialHeapSize

-Xmx<size>

设置最大Java堆大小,等价于-XX:MaxHeapSize

-Xss<size>

设置Java线程堆栈大小,-XX:ThreadStackSize

类型三:-XX参数选项

特点

非标准化参数;使用的最多的参数类型;这类选项属于实验性,不稳定;以-XX开头

作用

用于开发和调试JVM

分类

1、Boolean类型格式

-XX:+<option>表示启用option属性

-XX:-<option>表示禁用option属性

举例:

-XX:-UseParallelGC 不选择垃圾收集器为并行收集器

-XX:+UseG1GC 表示启用G1收集器

-XX:+UseAdaptiveSizePolicy 自动选择年轻代区大小和相应的Survivor区比例

说明:因为有的指令默认是开启的,所以可以-使用关闭

2、非Boolean类型格式(key-value类型)

子类型1:数值型格式-XX:<option>=<number>

number表示数值,number可以带上单位,比如:'m' 、'M' 表示兆, 'k' 、'K' 表示Kb, 'g' 、 'G' 表示 g(例如 32k跟32768是一样的效果)

例如:

-XX:NewSize=1024m 表示设置新生代初始大小为1024兆

-XX:MaxGCPauseMillis=500 表示设置GC停顿时间:500毫秒

-XX:GCTimeRatio=19 表示设置吞吐量

-XX:NewRatio=2 表示新生代与老年代的比例

子类型2:非数值型格式-XX:<name>=<string>

例如:-XX:HeapDumpPath=/usr/local/heapdump.hprof 用来指定heap转存文件的存储路径。

特别地

-XX:+PrintFlagsFinal

输出所有参数的名称和默认值

默认不包括Diagnostic和Experimental的参数

可以配合-XX:+UnlockDiagnosticVMOptions和-XX:UnlockExperimentalVMOptions使用

各种参数默认值(参考)

cs 复制代码
[Global flags]

     intx ActiveProcessorCount                      = -1                                  {product}

    uintx AdaptiveSizeDecrementScaleFactor          = 4                                   {product}

    uintx AdaptiveSizeMajorGCDecayTimeScale         = 10                                  {product}

    uintx AdaptiveSizePausePolicy                   = 0                                   {product}

    uintx AdaptiveSizePolicyCollectionCostMargin    = 50                                  {product}

    uintx AdaptiveSizePolicyInitializingSteps       = 20                                  {product}

    uintx AdaptiveSizePolicyOutputInterval          = 0                                   {product}

    uintx AdaptiveSizePolicyWeight                  = 10                                  {product}

    uintx AdaptiveSizeThroughPutPolicy              = 0                                   {product}

    uintx AdaptiveTimeWeight                        = 25                                  {product}

     bool AdjustConcurrency                         = false                               {product}

     bool AggressiveHeap                            = false                               {product}

     bool AggressiveOpts                            = false                               {product}

     intx AliasLevel                                = 3                                   {C2 product}

     bool AlignVector                               = true                                {C2 product}

     intx AllocateInstancePrefetchLines             = 1                                   {product}

     intx AllocatePrefetchDistance                  = 256                                 {product}

     intx AllocatePrefetchInstr                     = 3                                   {product}

     intx AllocatePrefetchLines                     = 3                                   {product}

     intx AllocatePrefetchStepSize                  = 64                                  {product}

     intx AllocatePrefetchStyle                     = 1                                   {product}

     bool AllowJNIEnvProxy                          = false                               {product}

     bool AllowNonVirtualCalls                      = false                               {product}

     bool AllowParallelDefineClass                  = false                               {product}

     bool AllowUserSignalHandlers                   = false                               {product}

     bool AlwaysActAsServerClassMachine             = false                               {product}

     bool AlwaysCompileLoopMethods                  = false                               {product}

     bool AlwaysLockClassLoader                     = false                               {product}

     bool AlwaysPreTouch                            = false                               {product}

     bool AlwaysRestoreFPU                          = false                               {product}

     bool AlwaysTenure                              = false                               {product}

     bool AssertOnSuspendWaitFailure                = false                               {product}

     bool AssumeMP                                  = false                               {product}

     intx AutoBoxCacheMax                           = 128                                 {C2 product}

    uintx AutoGCSelectPauseMillis                   = 5000                                {product}

     intx BCEATraceLevel                            = 0                                   {product}

     intx BackEdgeThreshold                         = 100000                              {pd product}

     bool BackgroundCompilation                     = true                                {pd product}

    uintx BaseFootPrintEstimate                     = 268435456                           {product}

     intx BiasedLockingBulkRebiasThreshold          = 20                                  {product}

     intx BiasedLockingBulkRevokeThreshold          = 40                                  {product}

     intx BiasedLockingDecayTime                    = 25000                               {product}

     intx BiasedLockingStartupDelay                 = 4000                                {product}

     bool BindGCTaskThreadsToCPUs                   = false                               {product}

     bool BlockLayoutByFrequency                    = true                                {C2 product}

     intx BlockLayoutMinDiamondPercentage           = 20                                  {C2 product}

     bool BlockLayoutRotateLoops                    = true                                {C2 product}

     bool BranchOnRegister                          = false                               {C2 product}

     bool BytecodeVerificationLocal                 = false                               {product}

     bool BytecodeVerificationRemote                = true                                {product}

     bool C1OptimizeVirtualCallProfiling            = true                                {C1 product}

     bool C1ProfileBranches                         = true                                {C1 product}

     bool C1ProfileCalls                            = true                                {C1 product}

     bool C1ProfileCheckcasts                       = true                                {C1 product}

     bool C1ProfileInlinedCalls                     = true                                {C1 product}

     bool C1ProfileVirtualCalls                     = true                                {C1 product}

     bool C1UpdateMethodData                        = true                                {C1 product}

     intx CICompilerCount                          := 12                                  {product}

     bool CICompilerCountPerCPU                     = true                                {product}

     bool CITime                                    = false                               {product}

     bool 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 CheckEndorsedAndExtDirs                   = false                               {product}

     bool CheckJNICalls                             = false                               {product}

     bool ClassUnloading                            = true                                {product}

     bool ClassUnloadingWithConcurrentMark          = true                                {product}

     intx ClearFPUAtPark                            = 0                                   {product}

     bool ClipInlining                              = true                                {product}

    uintx CodeCacheExpansionSize                    = 65536                               {pd product}

    uintx CodeCacheMinimumFreeSpace                 = 512000                              {product}

     bool CollectGen0First                          = false                               {product}

     bool CompactFields                             = true                                {product}

     intx CompilationPolicyChoice                   = 3                                   {product}

ccstrlist CompileCommand                            =                                     {product}

    ccstr CompileCommandFile                        =                                     {product}

ccstrlist CompileOnly                               =                                     {product}

     intx CompileThreshold                          = 10000                               {pd product}

     bool CompilerThreadHintNoPreempt               = true                                {product}

     intx CompilerThreadPriority                    = -1                                  {product}

     intx CompilerThreadStackSize                   = 0                                   {pd product}

    uintx CompressedClassSpaceSize                  = 1073741824                          {product}

    uintx ConcGCThreads                             = 0                                   {product}

     intx ConditionalMoveLimit                      = 3                                   {C2 pd product}

     intx ContendedPaddingWidth                     = 128                                 {product}

     bool ConvertSleepToYield                       = true                                {pd product}

     bool ConvertYieldToSleep                       = false                               {product}

     bool CrashOnOutOfMemoryError                   = false                               {product}

     bool CreateMinidumpOnCrash                     = false                               {product}

     bool CriticalJNINatives                        = true                                {product}

     bool DTraceAllocProbes                         = false                               {product}

     bool DTraceMethodProbes                        = false                               {product}

     bool DTraceMonitorProbes                       = false                               {product}

     bool Debugging                                 = false                               {product}

    uintx DefaultMaxRAMFraction                     = 4                                   {product}

     intx DefaultThreadPriority                     = -1                                  {product}

     intx DeferPollingPageLoopCount                 = -1                                  {product}

     intx DeferThrSuspendLoopCount                  = 4000                                {product}

     bool DeoptimizeRandom                          = false                               {product}

     bool DisableAttachMechanism                    = false                               {product}

     bool DisableExplicitGC                         = false                               {product}

     bool DisplayVMOutputToStderr                   = false                               {product}

     bool DisplayVMOutputToStdout                   = false                               {product}

     bool DoEscapeAnalysis                          = true                                {C2 product}

     bool DontCompileHugeMethods                    = true                                {product}

     bool DontYieldALot                             = false                               {pd product}

    ccstr DumpLoadedClassList                       =                                     {product}

     bool DumpReplayDataOnError                     = true                                {product}

     bool DumpSharedSpaces                          = false                               {product}

     bool EagerXrunInit                             = false                               {product}

     intx EliminateAllocationArraySizeLimit         = 64                                  {C2 product}

     bool EliminateAllocations                      = true                                {C2 product}

     bool EliminateAutoBox                          = true                                {C2 product}

     bool EliminateLocks                            = true                                {C2 product}

     bool EliminateNestedLocks                      = true                                {C2 product}

     intx EmitSync                                  = 0                                   {product}

     bool EnableContended                           = true                                {product}

     bool EnableResourceManagementTLABCache         = true                                {product}

     bool EnableSharedLookupCache                   = true                                {product}

     bool EnableTracing                             = false                               {product}

    uintx ErgoHeapSizeLimit                         = 0                                   {product}

    ccstr ErrorFile                                 =                                     {product}

    ccstr ErrorReportServer                         =                                     {product}

   double EscapeAnalysisTimeout                     = 20.000000                           {C2 product}

     bool EstimateArgEscape                         = true                                {product}

     bool ExitOnOutOfMemoryError                    = false                               {product}

     bool ExplicitGCInvokesConcurrent               = false                               {product}

     bool ExplicitGCInvokesConcurrentAndUnloadsClasses  = false                               {product}

     bool ExtendedDTraceProbes                      = false                               {product}

    ccstr ExtraSharedClassListFile                  =                                     {product}

     bool FLSAlwaysCoalesceLarge                    = false                               {product}

    uintx FLSCoalescePolicy                         = 2                                   {product}

   double FLSLargestBlockCoalesceProximity          = 0.990000                            {product}

     bool FailOverToOldVerifier                     = true                                {product}

     bool FastTLABRefill                            = true                                {product}

     intx FenceInstruction                          = 0                                   {ARCH product}

     intx FieldsAllocationStyle                     = 1                                   {product}

     bool FilterSpuriousWakeups                     = true                                {product}

    ccstr FlightRecorderOptions                     =                                     {product}

     bool ForceNUMA                                 = false                               {product}

     bool ForceTimeHighResolution                   = false                               {product}

     intx FreqInlineSize                            = 325                                 {pd product}

   double 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}

    uintx GCDrainStackTargetSize                    = 64                                  {product}

    uintx GCHeapFreeLimit                           = 2                                   {product}

    uintx GCLockerEdenExpansionPercent              = 5                                   {product}

     bool GCLockerInvokesConcurrent                 = false                               {product}

    uintx GCLogFileSize                             = 8192                                {product}

    uintx GCPauseIntervalMillis                     = 0                                   {product}

    uintx GCTaskTimeStampEntries                    = 200                                 {product}

    uintx GCTimeLimit                               = 98                                  {product}

    uintx GCTimeRatio                               = 99                                  {product}

    uintx HeapBaseMinAddress                        = 2147483648                          {pd product}

     bool HeapDumpAfterFullGC                       = false                               {manageable}

     bool HeapDumpBeforeFullGC                      = false                               {manageable}

     bool HeapDumpOnOutOfMemoryError                = false                               {manageable}

    ccstr HeapDumpPath                              =                                     {manageable}

    uintx HeapFirstMaximumCompactionCount           = 3                                   {product}

    uintx HeapMaximumCompactionInterval             = 20                                  {product}

    uintx HeapSizePerGCThread                       = 87241520                            {product}

     bool IgnoreEmptyClassPaths                     = false                               {product}

     bool IgnoreUnrecognizedVMOptions               = false                               {product}

    uintx IncreaseFirstTierCompileThresholdAt       = 50                                  {product}

     bool IncrementalInline                         = true                                {C2 product}

    uintx InitialBootClassLoaderMetaspaceSize       = 4194304                             {product}

    uintx InitialCodeCacheSize                      = 2555904                             {pd product}

    uintx InitialHeapSize                          := 526385152                           {product}

    uintx InitialRAMFraction                        = 64                                  {product}

   double InitialRAMPercentage                      = 1.562500                            {product}

    uintx InitialSurvivorRatio                      = 8                                   {product}

    uintx InitialTenuringThreshold                  = 7                                   {product}

    uintx InitiatingHeapOccupancyPercent            = 45                                  {product}

     bool Inline                                    = true                                {product}

    ccstr InlineDataFile                            =                                     {product}

     intx InlineSmallCode                           = 2000                                {pd product}

     bool InlineSynchronizedMethods                 = true                                {C1 product}

     bool InsertMemBarAfterArraycopy                = true                                {C2 product}

     intx InteriorEntryAlignment                    = 16                                  {C2 pd product}

     intx InterpreterProfilePercentage              = 33                                  {product}

     bool JNIDetachReleasesMonitors                 = true                                {product}

     bool JavaMonitorsInStackTrace                  = true                                {product}

     intx JavaPriority10_To_OSPriority              = -1                                  {product}

     intx JavaPriority1_To_OSPriority               = -1                                  {product}

     intx JavaPriority2_To_OSPriority               = -1                                  {product}

     intx JavaPriority3_To_OSPriority               = -1                                  {product}

     intx JavaPriority4_To_OSPriority               = -1                                  {product}

     intx JavaPriority5_To_OSPriority               = -1                                  {product}

     intx JavaPriority6_To_OSPriority               = -1                                  {product}

     intx JavaPriority7_To_OSPriority               = -1                                  {product}

     intx JavaPriority8_To_OSPriority               = -1                                  {product}

     intx JavaPriority9_To_OSPriority               = -1                                  {product}

     bool LIRFillDelaySlots                         = false                               {C1 pd product}

    uintx LargePageHeapSizeThreshold                = 134217728                           {product}

    uintx LargePageSizeInBytes                      = 0                                   {product}

     bool LazyBootClassLoader                       = true                                {product}

     intx LiveNodeCountInliningCutoff               = 40000                               {C2 product}

     bool LoadExecStackDllInVMThread                = true                                {product}

     bool LogCommercialFeatures                     = false                               {product}

     intx LoopMaxUnroll                             = 16                                  {C2 product}

     intx LoopOptsCount                             = 43                                  {C2 product}

     intx LoopUnrollLimit                           = 60                                  {C2 pd product}

     intx LoopUnrollMin                             = 4                                   {C2 product}

     bool LoopUnswitching                           = true                                {C2 product}

     bool ManagementServer                          = false                               {product}

    uintx MarkStackSize                             = 4194304                             {product}

    uintx MarkStackSizeMax                          = 536870912                           {product}

    uintx MarkSweepAlwaysCompactCount               = 4                                   {product}

    uintx MarkSweepDeadRatio                        = 1                                   {product}

     intx MaxBCEAEstimateLevel                      = 5                                   {product}

     intx MaxBCEAEstimateSize                       = 150                                 {product}

    uintx MaxDirectMemorySize                       = 0                                   {product}

     bool MaxFDLimit                                = true                                {product}

    uintx MaxGCMinorPauseMillis                     = 18446744073709551615                    {product}

    uintx MaxGCPauseMillis                          = 18446744073709551615                    {product}

    uintx MaxHeapFreeRatio                          = 100                                 {manageable}

    uintx MaxHeapSize                              := 8417968128                          {product}

     intx MaxInlineLevel                            = 9                                   {product}

     intx MaxInlineSize                             = 35                                  {product}

     intx MaxJNILocalCapacity                       = 65536                               {product}

     intx MaxJavaStackTraceDepth                    = 1024                                {product}

     intx MaxJumpTableSize                          = 65000                               {C2 product}

     intx MaxJumpTableSparseness                    = 5                                   {C2 product}

     intx MaxLabelRootDepth                         = 1100                                {C2 product}

     intx MaxLoopPad                                = 11                                  {C2 product}

    uintx MaxMetaspaceExpansion                     = 5451776                             {product}

    uintx MaxMetaspaceFreeRatio                     = 70                                  {product}

    uintx MaxMetaspaceSize                          = 18446744073709547520                    {product}

    uintx MaxNewSize                               := 2805989376                          {product}

     intx MaxNodeLimit                              = 75000                               {C2 product}

 uint64_t MaxRAM                                    = 137438953472                        {pd product}

    uintx MaxRAMFraction                            = 4                                   {product}

   double MaxRAMPercentage                          = 25.000000                           {product}

     intx MaxRecursiveInlineLevel                   = 1                                   {product}

    uintx MaxTenuringThreshold                      = 15                                  {product}

     intx MaxTrivialSize                            = 6                                   {product}

     intx MaxVectorSize                             = 32                                  {C2 product}

    uintx MetaspaceSize                             = 21807104                            {pd product}

     bool MethodFlushing                            = true                                {product}

    uintx MinHeapDeltaBytes                        := 524288                              {product}

    uintx MinHeapFreeRatio                          = 0                                   {manageable}

     intx MinInliningThreshold                      = 250                                 {product}

     intx MinJumpTableSize                          = 10                                  {C2 pd product}

    uintx MinMetaspaceExpansion                     = 339968                              {product}

    uintx MinMetaspaceFreeRatio                     = 40                                  {product}

    uintx MinRAMFraction                            = 2                                   {product}

   double MinRAMPercentage                          = 50.000000                           {product}

    uintx MinSurvivorRatio                          = 3                                   {product}

    uintx MinTLABSize                               = 2048                                {product}

     intx MonitorBound                              = 0                                   {product}

     bool MonitorInUseLists                         = false                               {product}

     intx MultiArrayExpandLimit                     = 6                                   {C2 product}

     bool MustCallLoadClassInternal                 = false                               {product}

    uintx NUMAChunkResizeWeight                     = 20                                  {product}

    uintx NUMAInterleaveGranularity                 = 2097152                             {product}

    uintx NUMAPageScanRate                          = 256                                 {product}

    uintx NUMASpaceResizeRate                       = 1073741824                          {product}

     bool NUMAStats                                 = false                               {product}

    ccstr NativeMemoryTracking                      = off                                 {product}

     bool NeedsDeoptSuspend                         = false                               {pd product}

     bool NeverActAsServerClassMachine              = false                               {pd product}

     bool NeverTenure                               = false                               {product}

    uintx NewRatio                                  = 2                                   {product}

    uintx NewSize                                  := 175112192                           {product}

    uintx NewSizeThreadIncrease                     = 5320                                {pd product}

     intx NmethodSweepActivity                      = 10                                  {product}

     intx NmethodSweepCheckInterval                 = 5                                   {product}

     intx NmethodSweepFraction                      = 16                                  {product}

     intx NodeLimitFudgeFactor                      = 2000                                {C2 product}

    uintx NumberOfGCLogFiles                        = 0                                   {product}

     intx NumberOfLoopInstrToAlign                  = 4                                   {C2 product}

     intx ObjectAlignmentInBytes                    = 8                                   {lp64_product}

    uintx OldPLABSize                               = 1024                                {product}

    uintx OldPLABWeight                             = 50                                  {product}

    uintx OldSize                                  := 351272960                           {product}

     bool OmitStackTraceInFastThrow                 = true                                {product}

ccstrlist OnError                                   =                                     {product}

ccstrlist OnOutOfMemoryError                        =                                     {product}

     intx OnStackReplacePercentage                  = 140                                 {pd product}

     bool OptimizeFill                              = true                                {C2 product}

     bool OptimizePtrCompare                        = true                                {C2 product}

     bool OptimizeStringConcat                      = true                                {C2 product}

     bool OptoBundling                              = false                               {C2 pd product}

     intx OptoLoopAlignment                         = 16                                  {pd product}

     bool OptoScheduling                            = false                               {C2 pd product}

    uintx PLABWeight                                = 75                                  {product}

     bool PSChunkLargeArrays                        = true                                {product}

     intx ParGCArrayScanChunk                       = 50                                  {product}

    uintx ParGCDesiredObjsFromOverflowList          = 20                                  {product}

     bool ParGCTrimOverflow                         = true                                {product}

     bool ParGCUseLocalOverflow                     = false                               {product}

    uintx ParallelGCBufferWastePct                  = 10                                  {product}

    uintx ParallelGCThreads                         = 13                                  {product}

     bool ParallelGCVerbose                         = false                               {product}

    uintx ParallelOldDeadWoodLimiterMean            = 50                                  {product}

    uintx ParallelOldDeadWoodLimiterStdDev          = 80                                  {product}

     bool ParallelRefProcBalancingEnabled           = true                                {product}

     bool ParallelRefProcEnabled                    = false                               {product}

     bool PartialPeelAtUnsignedTests                = true                                {C2 product}

     bool PartialPeelLoop                           = true                                {C2 product}

     intx PartialPeelNewPhiDelta                    = 0                                   {C2 product}

    uintx PausePadding                              = 1                                   {product}

     intx PerBytecodeRecompilationCutoff            = 200                                 {product}

     intx PerBytecodeTrapLimit                      = 4                                   {product}

     intx PerMethodRecompilationCutoff              = 400                                 {product}

     intx PerMethodTrapLimit                        = 100                                 {product}

     bool PerfAllowAtExitRegistration               = false                               {product}

     bool PerfBypassFileSystemCheck                 = false                               {product}

     intx PerfDataMemorySize                        = 32768                               {product}

     intx PerfDataSamplingInterval                  = 50                                  {product}

    ccstr PerfDataSaveFile                          =                                     {product}

     bool PerfDataSaveToFile                        = false                               {product}

     bool PerfDisableSharedMem                      = false                               {product}

     intx PerfMaxStringConstLength                  = 1024                                {product}

     intx PreInflateSpin                            = 10                                  {pd product}

     bool PreferContainerQuotaForCPUCount           = true                                {product}

     bool PreferInterpreterNativeStubs              = false                               {pd product}

     intx PrefetchCopyIntervalInBytes               = 576                                 {product}

     intx PrefetchFieldsAhead                       = 1                                   {product}

     intx PrefetchScanIntervalInBytes               = 576                                 {product}

     bool PreserveAllAnnotations                    = false                               {product}

     bool PreserveFramePointer                      = false                               {pd product}

    uintx PretenureSizeThreshold                    = 0                                   {product}

     bool PrintAdaptiveSizePolicy                   = false                               {product}

     bool PrintCMSInitiationStatistics              = false                               {product}

     intx PrintCMSStatistics                        = 0                                   {product}

     bool PrintClassHistogram                       = false                               {manageable}

     bool PrintClassHistogramAfterFullGC            = false                               {manageable}

     bool PrintClassHistogramBeforeFullGC           = false                               {manageable}

     bool PrintCodeCache                            = false                               {product}

     bool PrintCodeCacheOnCompilation               = false                               {product}

     bool PrintCommandLineFlags                     = false                               {product}

     bool PrintCompilation                          = false                               {product}

     bool PrintConcurrentLocks                      = false                               {manageable}

     intx PrintFLSCensus                            = 0                                   {product}

     intx PrintFLSStatistics                        = 0                                   {product}

     bool PrintFlagsFinal                          := true                                {product}

     bool PrintFlagsInitial                         = false                               {product}

     bool PrintGC                                   = false                               {manageable}

     bool PrintGCApplicationConcurrentTime          = false                               {product}

     bool PrintGCApplicationStoppedTime             = false                               {product}

     bool PrintGCCause                              = true                                {product}

     bool PrintGCDateStamps                         = false                               {manageable}

     bool PrintGCDetails                            = false                               {manageable}

     bool PrintGCID                                 = false                               {manageable}

     bool PrintGCTaskTimeStamps                     = false                               {product}

     bool PrintGCTimeStamps                         = false                               {manageable}

     bool PrintHeapAtGC                             = false                               {product rw}

     bool PrintHeapAtGCExtended                     = false                               {product rw}

     bool PrintHeapAtSIGBREAK                       = true                                {product}

     bool PrintJNIGCStalls                          = false                               {product}

     bool PrintJNIResolving                         = false                               {product}

     bool PrintOldPLAB                              = false                               {product}

     bool PrintOopAddress                           = false                               {product}

     bool PrintPLAB                                 = false                               {product}

     bool PrintParallelOldGCPhaseTimes              = false                               {product}

     bool PrintPromotionFailure                     = false                               {product}

     bool PrintReferenceGC                          = false                               {product}

     bool PrintSafepointStatistics                  = false                               {product}

     intx PrintSafepointStatisticsCount             = 300                                 {product}

     intx PrintSafepointStatisticsTimeout           = -1                                  {product}

     bool PrintSharedArchiveAndExit                 = false                               {product}

     bool PrintSharedDictionary                     = false                               {product}

     bool PrintSharedSpaces                         = false                               {product}

     bool PrintStringDeduplicationStatistics        = false                               {product}

     bool PrintStringTableStatistics                = false                               {product}

     bool PrintTLAB                                 = false                               {product}

     bool PrintTenuringDistribution                 = false                               {product}

     bool PrintTieredEvents                         = false                               {product}

     bool PrintVMOptions                            = false                               {product}

     bool PrintVMQWaitTime                          = false                               {product}

     bool PrintWarnings                             = true                                {product}

    uintx ProcessDistributionStride                 = 4                                   {product}

     bool ProfileInterpreter                        = true                                {pd product}

     bool ProfileIntervals                          = false                               {product}

     intx ProfileIntervalsTicks                     = 100                                 {product}

     intx ProfileMaturityPercentage                 = 20                                  {product}

     bool ProfileVM                                 = false                               {product}

     bool ProfilerPrintByteCodeStatistics           = false                               {product}

     bool ProfilerRecordPC                          = false                               {product}

    uintx PromotedPadding                           = 3                                   {product}

    uintx QueuedAllocationWarningCount              = 0                                   {product}

    uintx RTMRetryCount                             = 5                                   {ARCH product}

     bool RangeCheckElimination                     = true                                {product}

     intx ReadPrefetchInstr                         = 0                                   {ARCH product}

     bool ReassociateInvariants                     = true                                {C2 product}

     bool ReduceBulkZeroing                         = true                                {C2 product}

     bool ReduceFieldZeroing                        = true                                {C2 product}

     bool ReduceInitialCardMarks                    = true                                {C2 product}

     bool ReduceSignalUsage                         = false                               {product}

     intx RefDiscoveryPolicy                        = 0                                   {product}

     bool ReflectionWrapResolutionErrors            = true                                {product}

     bool RegisterFinalizersAtInit                  = true                                {product}

     bool RelaxAccessControlCheck                   = false                               {product}

    ccstr ReplayDataFile                            =                                     {product}

     bool RequireSharedSpaces                       = false                               {product}

    uintx ReservedCodeCacheSize                     = 251658240                           {pd product}

     bool ResizeOldPLAB                             = true                                {product}

     bool ResizePLAB                                = true                                {product}

     bool ResizeTLAB                                = true                                {pd product}

     bool RestoreMXCSROnJNICalls                    = false                               {product}

     bool RestrictContended                         = true                                {product}

     bool RewriteBytecodes                          = true                                {pd product}

     bool RewriteFrequentPairs                      = true                                {pd product}

     intx SafepointPollOffset                       = 256                                 {C1 pd product}

     intx SafepointSpinBeforeYield                  = 2000                                {product}

     bool SafepointTimeout                          = false                               {product}

     intx SafepointTimeoutDelay                     = 10000                               {product}

     bool ScavengeBeforeFullGC                      = true                                {product}

     intx SelfDestructTimer                         = 0                                   {product}

    uintx SharedBaseAddress                         = 34359738368                         {product}

    ccstr SharedClassListFile                       =                                     {product}

    uintx SharedMiscCodeSize                        = 122880                              {product}

    uintx SharedMiscDataSize                        = 4194304                             {product}

    uintx SharedReadOnlySize                        = 16777216                            {product}

    uintx SharedReadWriteSize                       = 16777216                            {product}

     bool ShowMessageBoxOnError                     = false                               {product}

     intx SoftRefLRUPolicyMSPerMB                   = 1000                                {product}

     bool SpecialEncodeISOArray                     = true                                {C2 product}

     bool SplitIfBlocks                             = true                                {C2 product}

     intx StackRedPages                             = 1                                   {pd product}

     intx StackShadowPages                          = 20                                  {pd product}

     bool StackTraceInThrowable                     = true                                {product}

     intx StackYellowPages                          = 2                                   {pd product}

     bool StartAttachListener                       = false                               {product}

     intx StarvationMonitorInterval                 = 200                                 {product}

     bool StressLdcRewrite                          = false                               {product}

    uintx StringDeduplicationAgeThreshold           = 3                                   {product}

    uintx StringTableSize                           = 60013                               {product}

     bool SuppressFatalErrorMessage                 = false                               {product}

    uintx SurvivorPadding                           = 3                                   {product}

    uintx SurvivorRatio                             = 8                                   {product}

     intx SuspendRetryCount                         = 50                                  {product}

     intx SuspendRetryDelay                         = 5                                   {product}

     intx SyncFlags                                 = 0                                   {product}

    ccstr SyncKnobs                                 =                                     {product}

     intx SyncVerbose                               = 0                                   {product}

    uintx TLABAllocationWeight                      = 35                                  {product}

    uintx TLABRefillWasteFraction                   = 64                                  {product}

    uintx TLABSize                                  = 0                                   {product}

     bool TLABStats                                 = true                                {product}

    uintx TLABWasteIncrement                        = 4                                   {product}

    uintx TLABWasteTargetPercent                    = 1                                   {product}

    uintx TargetPLABWastePct                        = 10                                  {product}

    uintx TargetSurvivorRatio                       = 50                                  {product}

    uintx TenuredGenerationSizeIncrement            = 20                                  {product}

    uintx TenuredGenerationSizeSupplement           = 80                                  {product}

    uintx TenuredGenerationSizeSupplementDecay      = 2                                   {product}

     intx ThreadPriorityPolicy                      = 0                                   {product}

     bool ThreadPriorityVerbose                     = false                               {product}

    uintx ThreadSafetyMargin                        = 52428800                            {product}

     intx ThreadStackSize                           = 1024                                {pd product}

    uintx ThresholdTolerance                        = 10                                  {product}

     intx Tier0BackedgeNotifyFreqLog                = 10                                  {product}

     intx Tier0InvokeNotifyFreqLog                  = 7                                   {product}

     intx Tier0ProfilingStartPercentage             = 200                                 {product}

     intx Tier23InlineeNotifyFreqLog                = 20                                  {product}

     intx Tier2BackEdgeThreshold                    = 0                                   {product}

     intx Tier2BackedgeNotifyFreqLog                = 14                                  {product}

     intx Tier2CompileThreshold                     = 0                                   {product}

     intx Tier2InvokeNotifyFreqLog                  = 11                                  {product}

     intx Tier3BackEdgeThreshold                    = 60000                               {product}

     intx Tier3BackedgeNotifyFreqLog                = 13                                  {product}

     intx Tier3CompileThreshold                     = 2000                                {product}

     intx Tier3DelayOff                             = 2                                   {product}

     intx Tier3DelayOn                              = 5                                   {product}

     intx Tier3InvocationThreshold                  = 200                                 {product}

     intx Tier3InvokeNotifyFreqLog                  = 10                                  {product}

     intx Tier3LoadFeedback                         = 5                                   {product}

     intx Tier3MinInvocationThreshold               = 100                                 {product}

     intx Tier4BackEdgeThreshold                    = 40000                               {product}

     intx Tier4CompileThreshold                     = 15000                               {product}

     intx Tier4InvocationThreshold                  = 5000                                {product}

     intx Tier4LoadFeedback                         = 3                                   {product}

     intx Tier4MinInvocationThreshold               = 600                                 {product}

     bool TieredCompilation                         = true                                {pd product}

     intx TieredCompileTaskTimeout                  = 50                                  {product}

     intx TieredRateUpdateMaxTime                   = 25                                  {product}

     intx TieredRateUpdateMinTime                   = 1                                   {product}

     intx TieredStopAtLevel                         = 4                                   {product}

     bool TimeLinearScan                            = false                               {C1 product}

     bool TraceBiasedLocking                        = false                               {product}

     bool TraceClassLoading                         = false                               {product rw}

     bool TraceClassLoadingPreorder                 = false                               {product}

     bool TraceClassPaths                           = false                               {product}

     bool TraceClassResolution                      = false                               {product}

     bool TraceClassUnloading                       = false                               {product rw}

     bool TraceDynamicGCThreads                     = false                               {product}

     bool TraceGen0Time                             = false                               {product}

     bool TraceGen1Time                             = false                               {product}

    ccstr TraceJVMTI                                =                                     {product}

     bool TraceLoaderConstraints                    = false                               {product rw}

     bool TraceMetadataHumongousAllocation          = false                               {product}

     bool TraceMonitorInflation                     = false                               {product}

     bool TraceParallelOldGCTasks                   = false                               {product}

     intx TraceRedefineClasses                      = 0                                   {product}

     bool TraceSafepointCleanupTime                 = false                               {product}

     bool TraceSharedLookupCache                    = false                               {product}

     bool TraceSuspendWaitFailures                  = false                               {product}

     intx TrackedInitializationLimit                = 50                                  {C2 product}

     bool TransmitErrorReport                       = false                               {product}

     bool TrapBasedNullChecks                       = false                               {pd product}

     bool TrapBasedRangeChecks                      = false                               {C2 pd product}

     intx TypeProfileArgsLimit                      = 2                                   {product}

    uintx TypeProfileLevel                          = 111                                 {pd product}

     intx TypeProfileMajorReceiverPercent           = 90                                  {C2 product}

     intx TypeProfileParmsLimit                     = 2                                   {product}

     intx TypeProfileWidth                          = 2                                   {product}

     intx UnguardOnExecutionViolation               = 0                                   {product}

     bool UnlinkSymbolsALot                         = false                               {product}

     bool Use486InstrsOnly                          = false                               {ARCH product}

     bool UseAES                                    = true                                {product}

     bool UseAESIntrinsics                          = true                                {product}

     intx UseAVX                                    = 2                                   {ARCH product}

     bool UseAdaptiveGCBoundary                     = false                               {product}

     bool UseAdaptiveGenerationSizePolicyAtMajorCollection  = true                                {product}

     bool UseAdaptiveGenerationSizePolicyAtMinorCollection  = true                                {product}

     bool UseAdaptiveNUMAChunkSizing                = true                                {product}

     bool UseAdaptiveSizeDecayMajorGCCost           = true                                {product}

     bool UseAdaptiveSizePolicy                     = true                                {product}

     bool UseAdaptiveSizePolicyFootprintGoal        = true                                {product}

     bool UseAdaptiveSizePolicyWithSystemGC         = false                               {product}

     bool UseAddressNop                             = true                                {ARCH product}

     bool UseAltSigs                                = false                               {product}

     bool UseAutoGCSelectPolicy                     = false                               {product}

     bool UseBMI1Instructions                       = true                                {ARCH product}

     bool UseBMI2Instructions                       = true                                {ARCH product}

     bool UseBiasedLocking                          = true                                {product}

     bool UseBimorphicInlining                      = true                                {C2 product}

     bool UseBoundThreads                           = true                                {product}

     bool UseCLMUL                                  = true                                {ARCH product}

     bool UseCMSBestFit                             = true                                {product}

     bool UseCMSCollectionPassing                   = true                                {product}

     bool UseCMSCompactAtFullCollection             = true                                {product}

     bool UseCMSInitiatingOccupancyOnly             = false                               {product}

     bool UseCRC32Intrinsics                        = true                                {product}

     bool UseCodeCacheFlushing                      = true                                {product}

     bool UseCompiler                               = true                                {product}

     bool UseCompilerSafepoints                     = true                                {product}

     bool UseCompressedClassPointers               := true                                {lp64_product}

     bool UseCompressedOops                        := true                                {lp64_product}

     bool UseConcMarkSweepGC                        = false                               {product}

     bool UseCondCardMark                           = false                               {C2 product}

     bool UseContainerSupport                       = true                                {product}

     bool UseCountLeadingZerosInstruction           = true                                {ARCH product}

     bool UseCountTrailingZerosInstruction          = true                                {ARCH product}

     bool UseCountedLoopSafepoints                  = false                               {C2 product}

     bool UseCounterDecay                           = true                                {product}

     bool UseDivMod                                 = true                                {C2 product}

     bool UseDynamicNumberOfGCThreads               = false                               {product}

     bool UseFPUForSpilling                         = true                                {C2 product}

     bool UseFastAccessorMethods                    = false                               {product}

     bool UseFastEmptyMethods                       = false                               {product}

     bool UseFastJNIAccessors                       = true                                {product}

     bool UseFastStosb                              = true                                {ARCH product}

     bool UseG1GC                                   = false                               {product}

     bool UseGCLogFileRotation                      = false                               {product}

     bool UseGCOverheadLimit                        = true                                {product}

     bool UseGCTaskAffinity                         = false                               {product}

     bool UseHeavyMonitors                          = false                               {product}

     bool UseHugeTLBFS                              = false                               {product}

     bool UseInlineCaches                           = true                                {product}

     bool UseInterpreter                            = true                                {product}

     bool UseJumpTables                             = true                                {C2 product}

     bool UseLWPSynchronization                     = true                                {product}

     bool UseLargePages                             = false                               {pd product}

     bool UseLargePagesInMetaspace                  = false                               {product}

     bool UseLargePagesIndividualAllocation         = false                               {pd product}

     bool UseLinuxPosixThreadCPUClocks              = true                                {product}

     bool UseLockedTracing                          = false                               {product}

     bool UseLoopCounter                            = true                                {product}

     bool UseLoopInvariantCodeMotion                = true                                {C1 product}

     bool UseLoopPredicate                          = true                                {C2 product}

     bool UseMathExactIntrinsics                    = true                                {C2 product}

     bool UseMaximumCompactionOnSystemGC            = true                                {product}

     bool UseMembar                                 = false                               {pd product}

     bool UseMontgomeryMultiplyIntrinsic            = true                                {C2 product}

     bool UseMontgomerySquareIntrinsic              = true                                {C2 product}

     bool UseMulAddIntrinsic                        = true                                {C2 product}

     bool UseMultiplyToLenIntrinsic                 = true                                {C2 product}

     bool UseNUMA                                   = false                               {product}

     bool UseNUMAInterleaving                       = false                               {product}

     bool UseNewLongLShift                          = false                               {ARCH product}

     bool UseOSErrorReporting                       = false                               {pd product}

     bool UseOldInlining                            = true                                {C2 product}

     bool UseOnStackReplacement                     = true                                {pd product}

     bool UseOnlyInlinedBimorphic                   = true                                {C2 product}

     bool UseOprofile                               = false                               {product}

     bool UseOptoBiasInlining                       = true                                {C2 product}

     bool UsePSAdaptiveSurvivorSizePolicy           = true                                {product}

     bool UseParNewGC                               = false                               {product}

     bool UseParallelGC                            := true                                {product}

     bool UseParallelOldGC                          = true                                {product}

     bool UsePerfData                               = true                                {product}

     bool UsePopCountInstruction                    = true                                {product}

     bool UseRDPCForConstantTableBase               = false                               {C2 product}

     bool UseRTMDeopt                               = false                               {ARCH product}

     bool UseRTMLocking                             = false                               {ARCH product}

     bool UseSHA                                    = false                               {product}

     bool UseSHA1Intrinsics                         = false                               {product}

     bool UseSHA256Intrinsics                       = false                               {product}

     bool UseSHA512Intrinsics                       = false                               {product}

     bool UseSHM                                    = false                               {product}

     intx UseSSE                                    = 4                                   {product}

     bool UseSSE42Intrinsics                        = true                                {product}

     bool UseSerialGC                               = false                               {product}

     bool UseSharedSpaces                           = false                               {product}

     bool UseSignalChaining                         = true                                {product}

     bool UseSquareToLenIntrinsic                   = true                                {C2 product}

     bool UseStoreImmI16                            = false                               {ARCH product}

     bool UseStringDeduplication                    = false                               {product}

     bool UseSuperWord                              = true                                {C2 product}

     bool UseTLAB                                   = true                                {pd product}

     bool UseThreadPriorities                       = true                                {pd product}

     bool UseTransparentHugePages                   = false                               {product}

     bool UseTypeProfile                            = true                                {product}

     bool UseTypeSpeculation                        = true                                {C2 product}

     bool UseUnalignedLoadStores                    = false                               {ARCH product}

     bool UseVMInterruptibleIO                      = false                               {product}

     bool UseXMMForArrayCopy                        = true                                {product}

     bool UseXmmI2D                                 = false                               {ARCH product}

     bool UseXmmI2F                                 = false                               {ARCH product}

     bool UseXmmLoadAndClearUpper                   = true                                {ARCH product}

     bool UseXmmRegToRegMoveAll                     = true                                {ARCH product}

     bool VMThreadHintNoPreempt                     = false                               {product}

     intx VMThreadPriority                          = -1                                  {product}

     intx VMThreadStackSize                         = 1024                                {pd product}

     intx ValueMapInitialSize                       = 11                                  {C1 product}

     intx ValueMapMaxLoopSize                       = 8                                   {C1 product}

     intx ValueSearchLimit                          = 1000                                {C2 product}

     bool VerifyMergedCPBytecodes                   = true                                {product}

     bool VerifySharedSpaces                        = false                               {product}

     intx WorkAroundNPTLTimedWaitHang               = 1                                   {product}

    uintx YoungGenerationSizeIncrement              = 20                                  {product}

    uintx YoungGenerationSizeSupplement             = 80                                  {product}

    uintx YoungGenerationSizeSupplementDecay        = 8                                   {product}

    uintx YoungPLABSize                             = 4096                                {product}

     bool ZeroTLAB                                  = false                               {product}

     intx hashCode                                  = 5                                   {product}

添加JVM参数选项

运行jar包

java -Xms50m -Xmx50m -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -jar demo.jar

通过Tomcati运行war包

  • Linux系统下可以在tomcat/bin/catalina.sh中添加类似如下配置:JAVA_OPTS="-Xms512M -Xmx1024M"
  • Windows系统下在catalina.bat中添加类似如下配置:set "JAVA_OPTS=-Xms512M -Xmx1024M"

程序运行过程中

  • 使用jinfo -flag <name>=<value> <pid> 设置非Boolean类型参数
  • 使用jinfo -flag [+|-]<name> <pid> 设置Boolean类型参数

常用的JVM参数选项

打印设置的XX选项及值

-XX:+PrintCommandLineFlags

可以让在程序运行前打印出用户手动设置或者JVM自动设置的XX选项

-XX:+PrintFlagsInitial

表示打印出所有XX选项的默认值

-XX:+PrintFlagsFinal

表示打印出X选项在运行程序时生效的值

-XX:+PrintVMOptions

打印JVM的参数

堆、栈、方法区等内存大小设置

-Xss128k

设置每个线程的栈大小为128k;等价于-XX:ThreadStackSize=128k

堆内存

-Xms3550m

等价于-XX:nitialHeapSize,设置JVM初始堆内存为3550M

-Xmx3550m

等价于-XX:MaxHeapSize,设置JVM最大堆内存为3550M

-Xmn2g

设置年轻代大小为2G;官方推荐配置为整个堆大小的3/8

-XX:NewSize=1024m

设置年轻代初始值为1024M

-XX:MaxNewSize=1024m

设置年轻代最大值为1024M

-XX:SurvivorRatio=8

设置年轻代中Eden区与一个Survivor区的比值,默认为8

-XX:+UseAdaptiveSizePolicy

自动选择名区大小比例

-XX:NewRatio=4

设置老年代与年轻代(包括1个Eden和2个Survivor区)的比值

-XX:PretenureSizeThreadshold=1024

设置让大于此阈值的对象直接分配在老年代,单位为字节;只对Serial、ParNew收集器有效

-XX:MaxTenuringThreshold=15

默认值为15;新生代每次MinorGC后,还存活的对象年龄+1,当对象的年龄大于设置的这个值时就进入老年代

-XX:+PrintTenuringDistribution

让JVM在每次MinorGC后打印出当前使用的Survivort中对象的年龄分布

-XX:TargetSurvivorRatio

表示MinorGC结束后Survivor区域中占用空间的期望比例

方法区

永久代

-XX:PermSize=256m

设置永久代初始值为256M

-XX:MaxPermSize=256m

设置永久代最大值为256M

元空间

-XX:MetaspaceSize

初始空间大小

-XX:MaxMetaspaceSize

最大空间,默认没有限制

-XX:+UseCompressedOops

压缩对象指针

-XX:+UseCompressedClassPointers

压缩类指针

-XX:CompressedClassSpaceSize

设置Klass Metaspacef的大小,默认1G

直接内存

-XX:MaxDirectMemorySize

指定DirectMemory容量,若未指定,则默认与Java堆最大值一样

OutofMemory相关的选项

-XX:+HeapDumpOnOutOfMemoryError

表示在内存出现OOM的时候,把Heap转存(Dump)到文件以便后续分析

-XX:+HeapDumpBeforeFullGC

表示在出现FullGC之前,生成Heap转储文件

-XX:HeapDumpPath=<path>

指定heap转存文件的存储路径

-XX:OnOutOfMemoryError

指定一个可行性程序或者脚本的路径,当发生OOM的时候,去执行这个脚本

对OnOutOfMemoryError的运维处理:

以部署在linux系统/opt/Server目录下的Server.jar为例

1.在run.sh启动脚本中添加jvm参数:

-XX:OnOutOfMemoryError=/opt/Server/restart.sh

2.restart.sh脚本

linux环境:

#!/bin/bash

pid=$(ps -ef|grep Server.jar|awk '{if($8=="java") {print $2}}')

kill -9 $pid

cd /opt/Server/;sh run.sh

Windows环境:

echo off

wmic process where Name='java.exe' delete

cd D:\Server

start run.bat

垃圾收集器相关选项

7款经典收集器与垃圾分代之间的关系

垃圾收集器的组合关系

  1. 两个收集器间有连线,表明它们可以搭配使用:

Serial/Serial Old、Serial/CMS、ParNew/Serial Old、ParNew/CMS、Parallel Scavenge/Serial Old、Parallel Scavenge/Parallel Old、G1;

  1. 其中Serial Old作为CMS出现"Concurrent Mode Failure"失败的后备预案。

  2. (红色虚线)由于维护和兼容性测试的成本,在JDK 8时将Serial+CMS、ParNew+Serial Old这两个组合声明为废弃(JEP 173),并在JDK 9中完全取消了这些组合的支持(JEP214),即:移除。

  3. (绿色虚线)JDK 14中:弃用Parallel Scavenge和SerialOld GC组合 (JEP 366)

  4. (青色虚线)JDK 14中:删除CMS垃圾回收器 (JEP 363)

查看默认垃圾收集器

  • -XX:+PrintCommandLineFlags:查看命令行相关参数(包含使用的垃圾收集器)
  • 使用命令行指令:jinfo --flag 相关垃圾回收器参数 进程ID

Serial回收器

Serial收集器作为HotSpot中Client模式下的默认新生代垃圾收集器。Serial Old是运行在Client模式下默认的老年代的垃圾回收器。

-XX:+UseSerialGC

指定年轻代和老年代都使用串行收集器。等价于 新生代用Serial GC,且老年代用Serial Old GC。可以获得最高的单线程收集效率。

ParNew回收器

  • -XX:+UseParNewGC

手动指定使用ParNew收集器执行内存回收任务。它表示年轻代使用并行收集器,不影响老年代。

  • -XX:ParallelGCThreads=N

限制线程数量,默认开启和CPU数据相同的线程数。

Parallel回收器

  • -XX:+UseParallelGC 手动指定年轻代使用Parallel并行收集器执行内存回收任务。
  • -XX:+UseParallelOldGC 手动指定老年代都是使用并行回收收集器。
    • 分别适用于新生代和老年代。默认jdk8是开启的。
    • 上面两个参数,默认开启一个,另一个也会被开启。(互相激活)
  • -XX:ParallelGCThreads 设置年轻代并行收集器的线程数。一般地,最好与CPU数量相等,以避免过多的线程数影响垃圾收集性能。
    • 在默认情况下,当CPU 数量小于8个, ParallelGCThreads 的值等于CPU 数量。
    • 当CPU数量大于8个,ParallelGCThreads 的值等于3+[5*CPU_Count]/8] 。
  • -XX:MaxGCPauseMillis设置垃圾收集器最大停顿时间(即STW的时间)。单位是毫秒。
    • 为了尽可能地把停顿时间控制在MaxGCPauseMills以内,收集器在工作时会调整Java堆大小或者其他一些参数。
    • 对于用户来讲,停顿时间越短体验越好。但是在服务器端,我们注重高并发,整体的吞吐量。所以服务器端适合Parallel,进行控制。
    • 该参数使用需谨慎。
  • -XX:GCTimeRatio垃圾收集时间占总时间的比例(= 1 / (N + 1))。用于衡量吞吐量的大小。
    • 取值范围(0,100)。默认值99,也就是垃圾回收时间不超过1%。
    • 与前一个-XX:MaxGCPauseMillis参数有一定矛盾性。暂停时间越长,Radio参数就容易超过设定的比例。
  • -XX:+UseAdaptiveSizePolicy设置Parallel Scavenge收集器具有自适应调节策略
    • 在这种模式下,年轻代的大小、Eden和Survivor的比例、晋升老年代的对象年龄等参数会被自动调整,已达到在堆大小、吞吐量和停顿时间之间的平衡点。
    • 在手动调优比较困难的场合,可以直接使用这种自适应的方式,仅指定虚拟机的最大堆、目标的吞吐量(GCTimeRatio)和停顿时间(MaxGCPauseMills),让虚拟机自己完成调优工作。

CMS回收器

  • -XX:+UseConcMarkSweepGC手动指定使用CMS 收集器执行内存回收任务。
    • 开启该参数后会自动将-XX:+UseParNewGC打开。即:ParNew(Young区用)+CMS(Old区用)+Serial Old的组合。
  • -XX:CMSlnitiatingOccupanyFraction设置堆内存使用率的阈值,一旦达到该阈值,便开始进行回收。
    • JDK5及以前版本的默认值为68,即当老年代的空间使用率达到68%时,会执行一次CMS 回收。JDK6及以上版本默认值为92%
    • 如果内存增长缓慢,则可以设置一个稍大的值,大的阈值可以有效降低CMS的触发频率,减少老年代回收的次数可以较为明显地改善应用程序性能。反之,如果应用程序内存使用率增长很快,则应该降低这个阈值,以避免频繁触发老年代串行收集器。因此通过该选项便可以有效降低Full GC 的执行次数。
  • -XX:+UseCMSCompactAtFullCollection用于指定在执行完Full GC后对内存空间进行压缩整理,以此避免内存碎片的产生。不过由于内存压缩整理过程无法并发执行,所带来的问题就是停顿时间变得更长了。
  • -XX:CMSFullGCsBeforeCompaction设置在执行多少次Full GC后对内存空间进行压缩整理。
  • -XX:ParallelCMSThreads设置CMS的线程数量。
    • CMS 默认启动的线程数是(ParallelGCThreads+3)/4,ParallelGCThreads 是年轻代并行收集器的线程数。当CPU 资源比较紧张时,受到CMS收集器线程的影响,应用程序的性能在垃圾回收阶段可能会非常糟糕。

另外,CMS收集器还有如下常用参数:

  • -XX:ConcGCThreads:设置并发垃圾收集的线程数,默认该值是基于ParallelGCThreads计算出来的;
  • -XX:+UseCMSInitiatingOccupancyOnly:是否动态可调,用这个参数可以使CMS一直按CMSInitiatingOccupancyFraction设定的值启动
  • -XX:+CMSScavengeBeforeRemark:强制hotspot虚拟机在cms remark阶段之前做一次minor gc,用于提高remark阶段的速度;
  • -XX:+CMSClassUnloadingEnable:如果有的话,启用回收Perm 区(JDK8之前)
  • -XX:+CMSParallelInitialEnabled:用于开启CMS initial-mark阶段采用多线程的方式进行标记,用于提高标记速度,在Java8开始已经默认开启;
  • -XX:+CMSParallelRemarkEnabled:用户开启CMS remark阶段采用多线程的方式进行重新标记,默认开启;
  • -XX:+ExplicitGCInvokesConcurrent 、-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses这两个参数用户指定hotspot虚拟在执行System.gc()时使用CMS周期;
  • -XX:+CMSPrecleaningEnabled:指定CMS是否需要进行Pre cleaning这个阶段

说明:

  • JDK9新特性:CMS被标记为Deprecate了(JEP291)
    • 如果对JDK 9及以上版本的HotSpot虚拟机使用参数-XX:+UseConcMarkSweepGC来开启CMS收集器的话,用户会收到一个警告信息,提示CMS未来将会被废弃。
  • JDK14新特性:删除CMS垃圾回收器(JEP363)
    • 移除了CMS垃圾收集器,如果在JDK14中使用-XX:+UseConcMarkSweepGC的话,JVM不会报错,只是给出一个warning信息,但是不会exit。JVM会自动回退以默认GC方式启动JVM

OpenJDK 64-Bit Server VM warning: Ignoring option UseConcMarkSweepGC; support was removed in 14.0 and the VM will continue execution using the default collector.

G1回收器

  • -XX:+UseG1GC

手动指定使用G1收集器执行内存回收任务。

  • -XX:G1HeapRegionSize

设置每个Region的大小。值是2的幂,范围是1MB到32MB之间,目标是根据最小的Java堆大小划分出约2048个区域。默认是堆内存的1/2000。

  • -XX:MaxGCPauseMillis

设置期望达到的最大GC停顿时间指标(JVM会尽力实现,但不保证达到)。默认值是200ms

  • -XX:ParallelGCThread

设置STW时GC线程数的值。最多设置为8

  • -XX:ConcGCThreads

设置并发标记的线程数。将n设置为并行垃圾回收线程数(ParallelGCThreads)的1/4左右。

  • -XX:InitiatingHeapOccupancyPercent

设置触发并发GC周期的Java堆占用率阈值。超过此值,就触发GC。默认值是45。

  • -XX:G1NewSizePercent、-XX:G1MaxNewSizePercent

新生代占用整个堆内存的最小百分比(默认5%)、最大百分比(默认60%)

  • -XX:G1ReservePercent=10

保留内存区域,防止 to space(Survivor中的to区)溢出

Mixed GC调优参数:

注意:G1收集器主要涉及到Mixed GC,Mixed GC会回收young 区和部分old区。

G1关于Mixed GC调优常用参数:

  • -XX:InitiatingHeapOccupancyPercent:设置堆占用率的百分比(0到100)达到这个数值的时候触发global concurrent marking(全局并发标记),默认为45%。值为0表示间断进行全局并发标记。
  • -XX:G1MixedGCLiveThresholdPercent:设置Old区的region被回收时候的对象占比,默认占用率为85%。只有Old区的region中存活的对象占用达到了这个百分比,才会在Mixed GC中被回收。
  • -XX:G1HeapWastePercent:在global concurrent marking(全局并发标记)结束之后,可以知道所有的区有多少空间要被回收,在每次young GC之后和再次发生Mixed GC之前,会检查垃圾占比是否达到此参数,只有达到了,下次才会发生Mixed GC。
  • -XX:G1MixedGCCountTarget:一次global concurrent marking(全局并发标记)之后,最多执行Mixed GC的次数,默认是8。
  • -XX:G1OldCSetRegionThresholdPercent:设置Mixed GC收集周期中要收集的Old region数的上限。默认值是Java堆的10%

怎么选择垃圾回收器

  • 优先调整堆的大小让JVM自适应完成。
  • 如果内存小于100M,使用串行收集器
  • 如果是单核、单机程序,并且没有停顿时间的要求,串行收集器
  • 如果是多CPU、需要高吞吐量、允许停顿时间超过1秒,选择并行或者JVM自己选择
  • 如果是多CPU、追求低停顿时间,需快速响应(比如延迟不能超过1秒,如互联网应用),使用并发收集器。官方推荐G1,性能高。现在互联网的项目,基本都是使用G1。

特别说明:

  1. 没有最好的收集器,更没有万能的收集;

  2. 调优永远是针对特定场景、特定需求,不存在一劳永逸的收集器

GC日志相关选项

常用参数

-verbose:gc

输出gc日志信息,默认输出到标准输出;可以独立使用

-XX:+PrintGC

等同于-verbose:gc表示打开简化的GC日志;可以独立使用

-XX:+PrintGCDetails

在发生垃圾回收时打印内存回收详细的日志,并在进程退出时输出当前内存各区域分配情况;可以独立使用

-XX:+PrintGCTimeStamps

输出GC发生时的时间戳;不可以独立使用,需要配合-XX+PrintGCDetails使用

-XX:+PrintGCDateStamps

输出GC发生时的时间戳(以日期的形式,如2013-05-04T21:53:59,234+0800);不可以独立使用,需要配合-XX+PrintGCDetails使用

-XX:+PrintHeapAtGC

每一次GC前和GC后,都打印堆信息;可以独立使用

-Xloggc:<file>

把GC日志写入到一个文件中去,而不是打印到标准输出中

其他参数

-XX:+TraceClassLoading

监控类的加载

-XX:PrintGCApplicationStoppedTime

打印GC时线程的停顿时间

-XX:+PrintGCApplicationConcurrentTime

垃圾收集之前打印出应用未中断的执行时间

-XX:+PrintReferenceGC

记录回收了多少种不同引用类型的引用

-XX:+PrintTenuringDistribution

让JVM在每次MinorGC后打印出当前使用的Survivor中对象的年龄分布

-XX:+UseGCLogFileRotation

启用GC日志文件的自动转储

-XX:NumberOfGClogFiles=1

GC日志文件的循环数目

-XX:GCLogFileSize=1M

控制GC日志文件的大小

其他参数

-XX:+DisableExplicitGC

禁止hotspot执行System.gc(),默认禁用

-XX:ReservedCodeCacheSize=<n> [g|m|k]、-XX:InitialCodeCacheSize=<n >[g|m|k]

指定代码缓存的大小

-XX:+UseCodeCacheFlushing

使用该参数让jvm放弃一些被编译的代码,避免代码缓存被占满时VM切换到interpreted-only的情况

-XX:+DoEscapeAnalysis

开启逃逸分析

-XX:+UseBiasedLocking

开启偏向锁

-XX:+UseLargePages

开启使用大页面

-XX:+UseTLAB

使用TLAB,默认打开

-XX:+PrintTLAB

打印TLAB的使用情况

-XX:TLABSize

设置TLAB大小

按功能性质区分JVM参数选项

Java HotSpot VM中-XX:的可配置参数列表进行描述;

这些参数可以被松散的聚合成三类:

  • 行为参数(Behavioral Options):用于改变jvm的一些基础行为;
  • 性能调优(Performance Tuning):用于jvm的性能调优;
  • 调试参数(Debugging Options):一般用于打开跟踪、打印、输出等jvm参数,用于显示jvm更加详细的信息;

行为参数(功能开关)

-XX:-DisableExplicitGC 禁止调用System.gc();但jvm的gc仍然有效

-XX:+MaxFDLimit 最大化文件描述符的数量限制

-XX:+ScavengeBeforeFullGC 新生代GC优先于Full GC执行

-XX:+UseGCOverheadLimit 在抛出OOM之前限制jvm耗费在GC上的时间比例

-XX:-UseConcMarkSweepGC 对老生代采用并发标记交换算法进行GC

-XX:-UseParallelGC 启用并行GC

-XX:-UseParallelOldGC 对Full GC启用并行,当-XX:-UseParallelGC启用时该项自动启用

-XX:-UseSerialGC 启用串行GC

-XX:+UseThreadPriorities 启用本地线程优先级

性能调优

-XX:LargePageSizeInBytes=4m 设置用于Java堆的大页面尺寸

-XX:MaxHeapFreeRatio=70 GC后java堆中空闲量占的最大比例

-XX:MaxNewSize=size 新生成对象能占用内存的最大值

-XX:MaxPermSize=64m 老生代对象能占用内存的最大值

-XX:MinHeapFreeRatio=40 GC后java堆中空闲量占的最小比例

-XX:NewRatio=2 新生代内存容量与老生代内存容量的比例

-XX:NewSize=2.125m 新生代对象生成时占用内存的默认值

-XX:ReservedCodeCacheSize=32m 保留代码占用的内存容量

-XX:ThreadStackSize=512 设置线程栈大小,若为0则使用系统默认值

-XX:+UseLargePages 使用大页面内存

调试参数

-XX:-CITime 打印消耗在JIT编译的时间

-XX:ErrorFile=./hs_err_pid<pid>.log 保存错误日志或者数据到文件中

-XX:-ExtendedDTraceProbes 开启solaris特有的dtrace探针

-XX:HeapDumpPath=./java_pid<pid>.hprof 指定导出堆信息时的路径或文件名

-XX:-HeapDumpOnOutOfMemoryError 当首次遭遇OOM时导出此时堆中相关信息

-XX:OnError="<cmd args>;<cmd args>" 出现致命ERROR之后运行自定义命令

-XX:OnOutOfMemoryError="<cmd args>;<cmd args>" 当首次遭遇OOM时执行自定义命令

-XX:-PrintClassHistogram 遇到Ctrl-Break后打印类实例的柱状信息,与jmap -histo功能相同

-XX:-PrintConcurrentLocks 遇到Ctrl-Break后打印并发锁的相关信息,与jstack -l功能相同

-XX:-PrintCommandLineFlags 打印在命令行中出现过的标记

-XX:-PrintCompilation 当一个方法被编译时打印相关信息

-XX:-PrintGC 每次GC时打印相关信息

-XX:-PrintGC Details 每次GC时打印详细信息

-XX:-PrintGCTimeStamps 打印每次GC的时间戳

-XX:-TraceClassLoading 跟踪类的加载信息

-XX:-TraceClassLoadingPreorder 跟踪被引用到的所有类的加载信息

-XX:-TraceClassResolution 跟踪常量池

-XX:-TraceClassUnloading 跟踪类的卸载信息

-XX:-TraceLoaderConstraints 跟踪类加载器约束的相关信息

通过Java代码获取JVM参数

Java提供了java.lang.management包用于监视和管理Java虚拟机和Java运行时中的其他组件,它允许本地和远程监控和管理运行的Java虚拟机。其中ManagementFactory这个类还是挺常用的。另外还有Runtime类也可以获取一些内存、CPU核数等相关的数据。

通过这些api可以监控我们的应用服务器的堆内存使用情况,设置一些阈值进行报警等处理。

java 复制代码
/**
 *
 * 监控我们的应用服务器的堆内存使用情况,设置一些阈值进行报警等处理
 */
public class MemoryMonitor {
    public static void main(String[] args) {
        MemoryMXBean memorymbean = ManagementFactory.getMemoryMXBean();
        MemoryUsage usage = memorymbean.getHeapMemoryUsage();
        System.out.println("INIT HEAP: " + usage.getInit() / 1024 / 1024 + "m");
        System.out.println("MAX HEAP: " + usage.getMax() / 1024 / 1024 + "m");
        System.out.println("USE HEAP: " + usage.getUsed() / 1024 / 1024 + "m");
        System.out.println("\nFull Information:");
        System.out.println("Heap Memory Usage: " + memorymbean.getHeapMemoryUsage());
        System.out.println("Non-Heap Memory Usage: " + memorymbean.getNonHeapMemoryUsage());

        System.out.println("=======================通过java来获取相关系统状态============================ ");
        System.out.println("当前堆内存大小totalMemory " + (int) Runtime.getRuntime().totalMemory() / 1024 / 1024 + "m");// 当前堆内存大小
        System.out.println("空闲堆内存大小freeMemory " + (int) Runtime.getRuntime().freeMemory() / 1024 / 1024 + "m");// 空闲堆内存大小
        System.out.println("最大可用总堆内存maxMemory " + Runtime.getRuntime().maxMemory() / 1024 / 1024 + "m");// 最大可用总堆内存大小

    }
}

输出如下:

INIT HEAP: 100m

MAX HEAP: 96m

USE HEAP: 3m

Full Information:

Heap Memory Usage: init = 104857600(102400K) used = 3162256(3088K) committed = 100663296(98304K) max = 100663296(98304K)

Non-Heap Memory Usage: init = 2555904(2496K) used = 5207432(5085K) committed = 8060928(7872K) max = -1(-1K)

=======================通过java来获取相关系统状态========================

当前堆内存大小totalMemory 96m

空闲堆内存大小freeMemory 92m

最大可用总堆内存maxMemory 96m

java 复制代码
public class HeapSpaceInitial {
    public static void main(String[] args) {

        //返回Java虚拟机中的堆内存总量
        long initialMemory = Runtime.getRuntime().totalMemory() / 1024 / 1024;
        //返回Java虚拟机试图使用的最大堆内存量
        long maxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024;

        System.out.println("-Xms : " + initialMemory + "M");
        System.out.println("-Xmx : " + maxMemory + "M");

        System.out.println("系统内存大小为:" + maxMemory * 4.0 / 1024 + "G");
        System.out.println("系统内存大小为:" + initialMemory * 64.0 / 1024 + "G");
    }
}
相关推荐
柯34911 小时前
GC垃圾回收
java·jvm·垃圾回收
王佑辉11 小时前
【jvm】执行引擎是做什么
jvm
平头哥在等你12 小时前
C语言简答题答案
java·c语言·jvm
zhuzhihongNO113 小时前
JVM(JAVA虚拟机)内存溢出导致内存不足,Java运行时环境无法继续
java·开发语言·jvm·内存溢出·jvm内存溢出
MaxCosmos200113 小时前
读《Effective Java》笔记 - 条目7
java·jvm·笔记
学点东西吧.13 小时前
JVM(六、Java内存分配)
java·开发语言·jvm
极客先躯14 小时前
高级java每日一道面试题-2024年11月23日-JVM篇-什么时候会出发FullGC?
java·jvm·fullgc·jvm篇·老年代内存不足·system.gc·减少full gc的策略
m0_7482329219 小时前
JVM的内存区域划分
java·jvm·算法
guokanglun20 小时前
自动化的内存管理技术之垃圾回收机制-JavaScript引用数据内存回收机制
运维·jvm·自动化
极客先躯1 天前
高级java每日一道面试题-2024年11月24日-JVM篇-说说对象分配规则?
java·jvm···对象分配规则