JVM 常用参数


参数名称 含义 默认值 相关描述
内存管理参数
-Xms 初始堆大小 物理内存的1/64(<1GB) 默认(MinHeapFreeRatio参数可以调整)空余堆内存小于40%时,JVM就会增大堆直到-Xmx的最大限制.
-Xmx 最大堆大小 物理内存的1/4(<1GB) 默认(MaxHeapFreeRatio参数可以调整)空余堆内存大于70%时,JVM会减少堆直到 -Xms的最小限制
-Xmn Young代大小   只能使用在JDK1.4或之后的版本中,(之前的1.3/1.4版本中,可使用-XX:NewSize设置年轻代大小,用-XX:MaxNewSize设置年轻代最大值)
-Xss 每个线程的堆栈大小   设置 Java 线程堆栈大小,同-XX:ThreadStackSize类似,这两个参数在1.6以前,都是谁设置在后面,谁就生效;1.6版本以后,-Xss设置在后面,则以-Xss为准,-XXThreadStackSize设置在后面,则主线程以-Xss为准,其它线程以-XX:ThreadStackSize为准
ThreadStackSize     Thread Stack Size (in Kbytes). (0 means use default stack size) [Sparc: 512; Solaris x86: 320 (was 256 prior in 5.0 and earlier); Sparc 64 bit: 1024; Linux amd64: 1024 (was 0 in 5.0 and earlier); all others 0.] 

NewSize     Default size of new generation (in bytes)
MaxNewSize     Maximum size of new generation (in bytes). Since 1.4, MaxNewSize is computed as a function of NewRatio. 
如果同时设置了-Xmn和-XX:NewSize,-XX:MaxNewSize,则谁设置在后面,谁就生效;如果同时设置了-XX:NewSize -XX:MaxNewSize与-XX:NewRatio则实际生效的值是:min(MaxNewSize,max(NewSize, heap/(NewRatio+1)))
PermSize 初始Perm大小    
MaxPermSize 最大Perm大小 大部分情况下默认值为64M 永久代空间的最大值
NewRatio 年轻代(包括Eden和两个Survivor区)与年老代的比值(除去持久代)   Old/New的比值,默认值为2,表示Old代与Young代的比值为2比1,
Xms=Xmx并且设置了Xmn的情况下,该参数不需要进行设置。
SurvivorRatio Eden区与Survivor区的大小比值   Eden/Survivor的比例,设置为8,则两个Survivor区与一个Eden区的比值为2:8,一个Survivor区占整个年轻代的1/10
TargetSurvivorRatio     Desired percentage of survivor space used after scavenge.
MaxDirectMemorySize 直接内存大小 -Xmx  
DisableExplicitGC   关闭 忽略来自System.gc()方法出发的垃圾收集
ExplicitGCInvokesConcurrent   关闭 当收到System.gc()方法提交的垃圾收集申请时,使用CMS收集器进行收集
UseSerialGC   Client默认开启,其它默认关闭 虚拟机在Client模式下的默认值,打开后,使用Serial+SerialOld组合进行垃圾回收
UseParNewGC 对新生代使用并行垃圾回收器 关闭 打开后,使用ParNew+SerialOld组合进行垃圾回收
UseConcMarkSweepGC 使用CMS收集器 关闭 打开后,使用ParNew+CMS+SerialOld的组合进行垃圾回收,如果CMS出现Concurrent Mode Failure,则使用Serial Old进行垃圾回收
UseParallelGC   Server模式下默认开启,其它默认关闭 在Server模式下,打开此值,使用Parallel Scavenge + Serial Old组合进行垃圾回收
UseParallelOldGC   默认关闭 打开后,使用Parallel Scavenge  + Parallel Old收集器进行垃圾回收,打开此参数后,会自动打开UseParallelGC
SurvivorRatio   默认值是8 新生代Eden区域与Survivor区域的容值比
PretenureSizeThreshold   无默认值 直接晋升到老年代的对象大小,设置后,大于此参数值得对象将直接在老年代分配
MaxTenuringThreshold   默认值15 晋升到老年代对象的年龄,每个对象在坚持过一次MinorGC后,年龄就增加1,当超过这个参数值时,就进入老年代
UseAdoptiveSizePolicy   默认开启 动态调整堆中各个区域的大小以及进入老年代的年龄
HandlePromotionFailure   JDK1.5之前默认关闭,JDK1.6之后,默认开启 是否允许分配担保失败,即老年代的剩余最大连续空间不足以引用新生代的整个Eden和Survivor区的所有存活对象的极端情况(以此判断是否需要对老年代进行以此FullGC)
PrallelGCThreads   少于或等于8个CPU时,默认值为CPU的数量值,多余8个CPU时,比CPU数量小 设置并行GC时,进行内存回收的线程数目, Sets the number of garbage collection threads in the young and old parallel garbage collectors. The default value varies with the platform on which the JVM is running
UseG1GC     使用G1收集器
InitiatingHeapOccupancyPercent       Percentage of the (entire) heap occupancy to start a concurrent GC cycle. It is used by GCs that trigger a concurrent GC cycle based on the occupancy of the entire heap, not just one of the generations (e.g., G1). A value of 0 denotes 'do constant GC cycles'. The default value is 45.
ConcGCThreads     Number of threads concurrent garbage collectors will use. The default value varies with the platform on which the JVM is running
G1ReservePercent     Sets the amount of heap that is reserved as a false ceiling to reduce the possibility of promotion failure. The default value is 10.
G1HeapRegionSize     With G1 the Java heap is subdivided into uniformly sized regions. This sets the size of the individual sub-divisions. The default value of this parameter is determined ergonomically based upon heap size. The minimum value is 1Mb and the maximum value is 32Mb.
GCTimeRatio   默认值为99 GC时间占总时间的比例,默认值为99,即允许1%的GC时间。仅仅在Parallel Scavenge收集时有效,公式为1/(1+n)
MaxGCPauseMillis 每次年轻代垃圾回收的最长时间(最大暂停时间) 无默认值 设置GC最大的停顿时间,仅仅在使用Parallel Scavenge收集器和G1收集器时有效,如果无法满足此时间,JVM会自动调整年轻代大小,以满足此值。
Sets a target for the maximum GC pause time. This is a soft goal, and the JVM will make its best effort to achieve it.
CMSInitiatingOccupancyFraction   默认值为68 设置CMG收集器在老年代空间被使用多少后出发垃圾收集,仅仅在使用CMS收集器时有效
UseCMSInitiatingOccupancyOnly    默认关闭 仅仅使用手动定义的初始化值来确定何时触发CMS垃圾回收
CMSIncrementalMode     设置为增量模式,用于单CPU情况
UseCMSCompactAtFullCollection   默认开启 设置CMS收集器在完成垃圾收集后是否要进行一次内存碎片整理,仅在使用CMS收集器时有效
CMSFullGCBeforeCompaction   无默认值 设置CMS收集器在进行若干次垃圾收集后再启动一次内存碎片整理,仅在使用CMS收集时有效
CMSParallelRemarkEnabled     降低标记停顿
ScavengeBeforeFullGC   默认开启 在FullGC之前触发一次Minor GC
UseGCOverheadLimit   默认开启 禁止GC过程无限制的执行,如果过于频繁,就直接抛出OutOfMemory异常
UseTLAB   Server模式默认开启 优先在本地线程缓存中分配对象,避免内存分配时候的阻塞过程
MaxHeapFreeRatio   默认值为70 当Xmx值比Xms值大时,堆可以动态收缩和扩展,这个参数控制当堆的空闲空间大于指定比率时候,进行自动收缩,收缩的下限时Xms
MinHeapFreeRatio   默认值为40 当Xmx值比Xms值大时,堆可以动态收缩和扩展,这个参数控制当堆的空闲空间小于指定比率的时候,进行自动扩展,扩展的上限是Xmx
-Xnoclassgc 禁用类垃圾收集   关闭CLASS的垃圾回收功能,就是虚拟机加载的类,即便是不使用,没有实例也不会回收。如果一个类20分钟还没有使用,虚拟机会卸载这个类。如果这个类再次使用,虚拟机会重新加载这个类,由于虚拟机加载类包含了IO和内存分配的操作,因此加载时会对性能有所影响
CollectGen0First FullGC时是否先YGC 默认关闭  
SoftRefLRUPolicyMSPerMB 每兆堆空闲空间中SoftReference的存活时间 1秒 softly reachable objects will remain alive for some amount of time after the last time they were referenced. The default value is one second of lifetime per free megabyte in the heap
UseCompressedOops    

Enables the use of compressed pointers (object references represented as 32 bit offsets instead of 64-bit pointers) for optimized 64-bit performance with Java heap sizes less than 32gb. 使用compressed pointers 

即时编译参数
CompileThreshold   Client模式下默认值为1500,Server模式下默认值为10000 触发方法即时编译的阀值
OnStackReplacePercentage   Client模式下默认933,Server模式下默认值140 OSR比率,它是OSR即时编译阀值计算公式的一个参数,用于代替BackEdgeThreshold参数控制回边计数器的实际溢出阀值
ReservedCodeCacheSize   大部分情况下默认值为32M 即时编译器的代码缓存最大值
类型加载参数
UseSplitVerifier   默认开启 使用依赖StackMapTable信息的类型检查代替数据流分析,以加快字节码校验速度
FailOverToOldVerifier   默认开启 当类型校验失败时,是否允许回到老的类型推导校验方式进行校验,如果开启则允许
RelaxAccessControlCheck   默认关闭 在校验阶段放松对类型访问性的限制
多线程相关参数
UseSpinning   JDK1.6默认开启,JDK1.5默认关闭 开启自旋锁以避免线程频繁挂起起和唤醒
PreBlockSpin   默认值为0 使用自旋锁时默认的自旋次数
UseThreadPriorities   默认开启 使用本地线程优先级
UseBiasedLocking 锁机制的性能改善 默认开启 是否使用偏向锁,如果开启,则使用
UseFastAccessorMethods 原始类型的快速优化 默认开启 当频繁反射执行某个方法时,生成字节码类加快反射执行速度
性能参数
AggressiveOpts 加快编译 JDK1.6默认开启,JDK1.5默认关闭 使用激进的优化特性,这些特性一般是具备正面和负面双重影响的,需要根据具体应用特点分析才能够判定是否对性能有好处
UseLargePages   默认开启 如果可能,使用大内存分配,这项特性需要操作系统支持才行
LargePageSizeInBytes 内存页的大小不可设置过大, 会影响Perm的大小 默认为4M 使用指定大小的内存分页,这项特性需要操作系统支持才行
StringCache   默认开启 是否使用字符串缓存,开启则使用
AllocatePrefetchLines     Number of cache lines to load after the last object allocation using prefetch instructions generated in JIT compiled code. Default values are 1 if the last allocated object was an instance and 3 if it was an array.  
AllocatePrefetchStyle   1 Generated code style for prefetch instructions.
0 - no prefetch instructions are generate*d*,
1 - execute prefetch instructions after each allocation,
2 - use TLAB allocation watermark pointer to gate when prefetch instructions are executed 
AllocatePrefetchDistance     Sets the prefetch distance for object allocation. Memory about to be written with the value of new objects is prefetched into cache at this distance (in bytes) beyond the address of the last allocated object. Each Java thread has its own allocation point. The default value varies with the platform on which the JVM is running
InlineSmallCode       Inline a previously compiled method only if its generated native code size is less than this. The default value varies with the platform on which the JVM is running
MaxInlineSize   35 Maximum bytecode size of a method to be inlined
FreqInlineSize     Maximum bytecode size of a frequently executed method to be inlined. The default value varies with the platform on which the JVM is running
调试参数
PrintFlagsInitial   默认关闭 显示所有可设置参数及默认值
PrintFlagsFinal   默认关闭 打印虚拟机的参数信息(手动设置之后的值)
HeapDumpOnOutOfMemoryError   默认关闭 Dump heap to file when java.lang.OutOfMemoryError is thrown
HeapDumpPath=./java_pid<pi>.hprof     Path to directory or filename for heap dump
OnOutOfMemoryError="<cmd args>; <cmd args>"   无默认值 Run user-defined commands when an OutOfMemoryError is first thrown
OnError="<cmd args>;<cmd args>"   无默认值 当虚拟机抛出ERROR异常时,执行用户指定的指令
PrintClassHistogram   默认关闭 使用[ctrl]-[break]快捷键输出类统计状态,相当于jmap -histo的功能
PrintConcurrentLocks   默认关闭 打印J.U.C中锁的状态,Print java.util.concurrent locks in Ctrl-Break thread dump
PrintCommandLineFlags   默认关闭 Print flags that appeared on the command line
PrintCompilation   默认关闭 打印方法即时编译信息,Print message when a method is compiled
PrintGC   默认关闭 打印GC信息,Print messages at garbage collection
PrintGCDetails   默认关闭 打印GC的详细信息,Print more details at garbage collection
PrintGCTimeStamps   默认关闭 打印GC停顿耗时,Print timestamps at garbage collection
PrintGCDateStamps   默认关闭 (from JDK 6 update 4) :打印GC日期,适合于长期运行的服务器
PrintTenuringDistribution   默认关闭 Print tenuring age information
PrintAdaptiveSizePolicy     Enables printing of information about adaptive generation sizing
TraceClassResolution     Trace constant pool resolutions,打印所有静态类,常量的代码引用位置,用于debug
PrintGCApplicationStoppedTime   默认关闭 打印垃圾回收期间程序暂停的时间
PrintGCApplicationConcurrentTime   默认关闭 打印每次垃圾回收前,程序未中断的执行时间
PrintHeapAtGC   默认关闭 打印GC前后的详细堆栈信息
-Xloggc:<filename>     把相关日志信息记录到文件以便分析
UseGCLogFileRotation     Enabled GC log rotation, requires -Xloggc
NumberOfGCLogFiles   1 Set the number of files to use when rotating logs, must be >= 1. The rotated log files will use the following naming scheme, <filename>.0, <filename>.1, ..., <filename>.n-1
GCLogFileSize   8K The size of the log file at which point the log will be rotated, must be >= 8K
PrintTLAB   默认关闭 查看TLAB空间的使用情况
TraceClassLoading   默认关闭 打印类加载信息
TraceClassLoadingPreorder     Trace all classes loaded in order referenced (not loaded)
TraceClassUnloading   默认关闭 打印类卸载信息
TraceLoaderConstraints     Trace recording of loader constraints
PerfSaveDataToFile     Saves jvmstat binary data on exit
PrintInlining   默认关闭 打印方法类型信息
PrintCFGToFile   默认关闭 将CFG图信息输出到文件,只有DEBUG版本虚拟机才支持的参数
PrintIdealGraphFile   默认关闭 将Ideal图信息输出d
UnlockDiagnosticVM Options   默认关闭 让虚拟机进入诊断模式,一次参数(如:PrintAssembly)需要在诊断模式中才能够使用
PrintAssembly   默认关闭 打印即时编译后的二进制信息
CITime     Prints time spent in JIT Compiler
ErrorFile=./hs_err_pid<pid>.log     If an error occurs, save the error data to this file

需了解更改有关HotSpot的参数信息,详见Oracle官方文档: http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
更多信息,请参考JDK官方文档: http://docs.oracle.com/javase/7/docs/
参考链接:
    Java 6 JVM参数选项大全(中文版): http://kenwublog.com/docs/java6-jvm-options-chinese-edition.htm
源代码参考位置:\hotspot\src\share\vm\runtime\globals.hpp  \hotspot\src\share\vm\runtime\globals.cpp " static  Flag flagTable[]"
未完待续......


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值