zoukankan      html  css  js  c++  java
  • JVM参数使用手册

    内存分配相关

    Xms
    英文释义:Initial heap size(in bytes)
    中文释义:堆区初始值
    使用方法:-Xms2g 或 -XX:InitialHeapSize=2048m

    Xmx
    英文释义:Maximum heap size(in bytes)
    中文释义:堆区最大值
    使用方法:-Xmx2g 或 -XX:MaxHeapSize=2048m

    Xmn
    英文释义:Maximum new generation size(in bytes)
    中文释义:新生代最大值
    使用方法:-Xmn512m 或 -XX:MaxNewSize=512m

    PermSizeMetaspaceSize
    英文释义:Initial size of permanent generation(in bytes)
    中文释义:永久代(元空间)初始值
    使用方法:-XX:PermSize=128m(1.7 之前版本)、-XX:MetaspaceSize=128m(1.7 之后版本)

    MaxPermSizeMetaspaceSize
    英文释义:Maximum size of permanent generation(in bytes)
    中文释义:永久代(元空间)最大值
    使用方法:-XX:MaxPermSize=256m(1.7之前版本)、-XX:MaxMetaspaceSize=256m(1.7之后版本)

    Xss
    英文释义:Thread Stack Size(in Kbytes)
    中文释义:线程栈最大值
    使用方法:-Xss256k 或 -XX:ThreadStackSize=256k

    GC 策略相关

    SurvivorRatio
    英文释义:Rato of eden/survivor space size
    中文释义:Eden 区和 Survivor 的比值
    使用方法:-XX:SurvivorRatio=6
    使用经验:默认值为 8,假如设为 6,则表示每个 Survivor 区跟 Eden 区的比值为1:6,每个 Survivor 区占新生代的八分之一

    PretenureSizeThreshold
    英文释义:Maximum size in bytes of objects allocated in DefNew generation;zero means no maximum
    中文释义:可以在新生代直接分配的对象最大值,0表示没有最大值
    使用方法:-XX:PretenureSizeThreshold=1000000
    使用经验:设置该参数,可以使大于这个值的对象直接在老年代分配,避免在 Eden 区和 Survivor 区发生大量的内存复制,该参数只对 Serial 和 ParNew 收集器有效,Parallel Scavenge并不认识该参数

    MaxTenuringThreshold
    英文释义:Maximum value fo tenuring threshold
    中文释义:新生代最大年龄
    使用方法:-XX:MaxTenuringThreshold=10
    使用经验:每个对象在坚持过一次Minor GC之后,年龄就增加1,当超过这个参数值时就进入老年代,最大支持15

    ParallelRefProcEnabled
    英文释义:Enable parallel reference processing whenever possible
    中文释义:尽可能启用并行引用处理
    使用方法:通过-XX:+ParallelRefProcEnabled开启,或者-XX:-ParallelRefProcEnabled关闭

    ParallelGCThreads
    英文释义:Number of parallel threads parallel gc will use
    中文释义:并行执行gc的线程数
    使用方法:-XX:ParallelGCThreads=16

    UseSerialGC
    英文释义:Use the Serial garbage collector
    中文释义:新生代使用 Serial 垃圾收集器
    使用方法:开启 -XX:+UseSerialGC、关闭 -XX:-UseSerialGC
    使用经验:虚拟机在运行在 Client 模式下的默认值,老年代将会使用 SerialOld 垃圾收集器

    UseParNewGC
    英文释义:Use parallel threads in the new generation
    中文释义:新生代使用 ParNew 垃圾收集器
    使用方法:开启 -XX:+UseParNewGC、关闭 -XX:-UseParNewGC
    使用经验:老年代将使用 Serial Old 收集器

    CMSParallelRemarkEnabled
    英文释义:Whether parallel remark enabled (only if ParNewGC)
    中文释义:是否启用并行标记(仅限于ParNewGC)
    使用方法:开启 -XX:+CMSParallelRemarkEnabled、关闭 -XX:-CMSParallelRemarkEnabled

    UseParallelGC
    英文释义:Use the Parallel Scavenge garbage collector
    中文释义:新生代使用 Parallel Scavenge 垃圾收集器
    使用方法:开启 -XX:+UseParallelGC、关闭 -XX:-UseParallelGC
    使用经验:Linux下1.6,1.7,1.8 默认开启(1.9 后默认启用 G1 收集器),老年代将会使用 Serial Old 垃圾收集器

    UseAdaptiveSizePolicy
    英文释义:Use adaptive generation sizing policies
    中文释义:自适应调节策略,动态调整 Java 堆中各个区域的大小以及进入老年代的年龄
    使用方法:开启 -XX:+UseAdaptiveSizePolicy、关闭 -XX:-UseAdaptiveSizePolicy

    MaxTimeRatio
    英文释义:
    中文释义:GC 时间占总时间的比率,默认值为 99,即允许 1% 的 GC 时间。仅在 Parallel Scavenge 收集器时生效。
    使用方法:-XX:MaxTimeRatio=99

    MaxGCPauseMillis
    英文释义:Adaptive size policy maximum GC pause time goal in millisecond, or (G1 Only) the maximum GC time per MMU time slice
    中文释义:自适应策略的最大GC暂停时间目标(以毫秒为单位),或(仅G1)每个MMU时间片的最大GC时间
    使用方法:-XX:MaxGCPauseMillis=200

    UseParallelOldGC
    英文释义:Use the Parallel Old garbage collector
    中文释义:老年代使用 Parallel Old 收集器
    使用方法:开启 -XX:+UseParallelOldGC、关闭 -XX:-UseParallelOldGC
    使用经验:新生代将使用 Parallel Scavenge 收集器

    UseConcMarkSweepGC
    英文释义:Use Concurrent Mark-Sweep GC in the old generation
    中文释义:老年代使用 CMS 收集器
    使用方法:开启 -XX:+UseConcMarkSweepGC、关闭 -XX:-UseConcMarkSweepGC
    使用经验:年轻代将会使用 ParNew 收集器,如果出现"Concurrent Mode Failure",会使用 Serial Old 收集器

    CMSInitiatingOccupancyFraction
    英文释义:Percentage CMS generation occupancy to start a CMS collection cycle. A negative value means that CMSTriggerRatio is used
    中文释义:触发执行 CMS 回收的老年代内存空间占用的百分比,负值表示使用 CMSTriggerRatio 设置的值
    使用方法:-XX:+CMSInitiatingOccupancyFraction=75

    UseCMSInitiatingOccupancyOnly
    英文释义:Only use occupancy as a criterion for staring a CMS collection
    中文释义:只根据占用情况作为开始执行CMS收集的标准
    使用方法:开启 -XX:+UseCMSInitiatingOccupancyOnly、关闭 -XX:-UseCMSInitiatingOccupancyOnly

    UseCMSCompactAtFullCollection
    英文释义:Use Mark-Sweep-Compact algorithm at full collections
    中文释义:设置 CMS 收集器在完成垃圾收集后是否要进行一次碎片整理
    使用方法:开启 -XX:+UseCMSCompactAtFullCollection、关闭 -XX:-UseCMSCompactAtFullCollection

    CMSFullGCsBeforeCompaction
    英文释义:Number of CMS full collection done before compaction if > 0
    中文释义:设置 CMS 收集器在进行若干次垃圾收集后再启动一次内存碎片整理。
    使用方法:-XX:CMSFullGCsBeforeCompaction=1

    CMSClassUnloadingEnabled
    英文释义:Whether class unloading enabled when using CMS GC
    中文释义:当使用CMS GC时是否启用类卸载功能
    使用方法:开启 -XX:+CMSClassUnloadingEnabled、关闭 -XX:-CMSClassUnloadingEnabled

    UseG1GC
    英文释义:Use the Garbage-First garbage collector
    中文释义:使用G1垃圾收集器
    使用方法:开启 -XX:+UseG1GC、关闭 -XX:-UseG1GC
    使用经验:JDK 1.9 后默认选择的垃圾收集器

    DisableExplicitGC
    英文释义:Ignore calls to System.gc()
    中文释义:禁用 System.gc() 触发FullGC
    使用方法:开启 -XX:+DisableExplicitGC、关闭 -XX:-DisableExplicitGC
    使用经验:不建议开启,如果开启了这个参数可能会导致对外内存无法及时回收造成对外内存溢出

    GC日志相关

    Xloggc
    英文释义:GC log file
    中文释义:GC日志文件路径
    使用方法:-Xloggc:/data/gclog/gc.log

    UseGCLogFileRotation
    英文释义:Rotate gclog files(for long running applications). It requires -Xloggc:
    中文释义:滚动GC日志文件,须配置Xloggc
    使用方法:开启 -XX:+UseGCLogFileRotation、关闭 -XX:-UseGCLogFileRotation

    NumberOfGCLogFiles
    英文释义:Number of gclog files in rotation(default:0,no rotation)
    中文释义:滚动 GC日志文件数,默认0,不滚动
    使用方法:-XX:NumberOfGCLogFiles=4

    GCLogFileSize
    英文释义:GC log file size,requires UseGCLogFileRotation. Set to 0 to only trigger rotation via jcmd
    中文释义:GC文件滚动大小,需配置UseGCLogFileRotation,设置为0表示仅通过jcmd命令触发
    使用方法:-XX:GCLogFileSize=100k

    PrintGCDetails
    英文释义:Print more details at garbage collection
    中文释义:GC时打印更多详细信息
    使用方法:开启 -XX:+PrintGCDetails、关闭 -XX:-PrintGCDetails
    使用经验:可以通过jinfo -flag [+|-]PrintGCDetails 或 jinfo -flag PrintGCDetails= 来动态开启或设置值

    PrintGCDateStamps
    英文释义:Print date stamps at garbage collection
    中文释义:GC时打印时间戳信息
    使用方法:开启 -XX:+PrintGCDateStamps、关闭 -XX:-PrintGCDateStamps
    使用经验:可以通过jinfo -flag [+|-] PrintGCDateStamps 或 jinfo -flag PrintGCDateStamps= 来动态开启或设置值

    PrintTenuringDistribution
    英文释义:Print tenuring age information
    中文释义:打印存活实例年龄信息
    使用方法:开启 -XX:+PrintTenuringDistribution、关闭 -XX:-PrintTenuringDistribution

    PrintGCApplicationStoppedTime
    英文释义:Print the time of application has been stopped
    中文释义:打印应用暂停时间
    使用方法:开启 -XX:+PrintGCApplicationStoppedTime、关闭 -XX:-PrintGCApplicationStoppedTime

    PrintHeapAtGC
    英文释义:Print heap layout before and after each GC
    中文释义:GC前后打印堆区使用信息
    使用方法:开启 -XX:+PrintHeapAtGC、关闭 -XX:-PrintHeapAtGC

    异常相关

    HeapDumpOnOutOfMemoryError
    英文释义:Dump heap to file when java.lang.OutOfMemoryError is thrown
    中文释义:抛出内存溢出错误时导出堆信息到指定文件
    使用方法:开启 -XX:+HeapDumpOnOutOfMemoryError、关闭 -XX:-HeapDumpOnOutOfMemoryError
    使用经验:可以通过 jinfo -flag [+|-]HeapDumpOnOutOfMemoryError 或 jinfo -flag HeapDumpOnOutOfMemoryError= 来动态开启或设置值

    HeapDumpPath
    英文释义:When HeapDumpOnOutOfMemoryError is on, the path(filename or directory) of the dump file(defaults to java_pid.hprof in the working directory)
    中文释义:当 HeapDumpOnOutOfMemoryError 开启的时候,dump 文件的保存路径,默认为工作目录下的 java_pid.hprof 文件
    使用方法:-XX:HeapDumpPath=/data/dump/jvm.dump

    其他

    server
    英文释义:server mode
    中文释义:服务端模式
    使用方法:-server

    TieredCompilation
    英文释义:Enable tiered compilation
    中文释义:启用多层编译
    使用方法:开启 -XX:+TieredCompilation、关闭 -XX:-TieredCompilation

  • 相关阅读:
    Java日期与时间的处理/Date,String,Calendar转换
    swift中的&---文章过时重置
    函数
    分支语句?
    NSDateFormatter 'YYYY' 和 'yyyy' 的区别
    swift字典集合---文章过时重置
    Swift字符串的插入、删除和替换-备
    PHP 时间函数集合
    PHP 正则通配符
    PHP的数据库 之 关闭问题
  • 原文地址:https://www.cnblogs.com/jmcui/p/12051328.html
Copyright © 2011-2022 走看看