java hotspot vm 非标准选项(翻译)

本文提供了典型的影响java hotspot虚拟机性能特征命令行选项和环境变量。除非在别的地方标注了,所有这篇文档的内容适用于java hotspot client和server虚拟机。 

java hotspot虚拟机选项分类

被java hotspot 虚拟机识别的标准选项在 Windows , Solaris  ,   Linux java 应用程序启动参考页面已经描述过。这篇文章专门论述被java hotspot 虚拟机识别的非标准选项:
. 以 -X开头的选项是非标准的(不保证在所有虚拟机实现都被支持),并且很容易在接下来的jdk发布版本中改变而没有通知
. 以-XX开始的选项不稳定并且很容易在没有通知的情况下改变
使用1.3.0以前版本的jdk用户如果希望迁移到java hotspot(jdk1.3.0以前使用的是exact 虚拟机) 虚拟机可以参考   Java HotSpot Equivalents of Exact VM flags

一些有用的-XX 选项

java se 6 在solaris平台的-server默认值都被列出。有些选项在不同的硬件架构/操作系统/jvm版本会不同。不同平台的不容默认值
在描述中列出。
boolean 选项用-XX:+<option>开启,用-XX:-<option>关闭
. 数字选项用-XX:<option>=<number>来设置。数字可以包含'm'或者'M'来表示兆字节,'k',或者'K'来表示千字节,'g',或者'G'来表示千兆字节(例如,32k和32768表达一个意思
. 数字选项用-XX:<option>=<string>来设置。通常用来指定一个文件,一个路径或者一列命令

被标记为可管理的的标志是可以通过jdk management接口和Jconsole( com.sun.management.HotSpotDiagnosticMXBean API)来动态修改.在   Monitoring and Managing Java SE 6 Platform Applications 这篇文档里,图片3给了一个例子。可管理的标示同样可以通过jino-flag来设置。

以下选项被大致分成类。
行为选项   改变虚拟机的基本行为
.  Garbage First(G1,备注jdk7默认的垃圾回收算法)  垃圾回收选项
.  性能调优选项  可以调节虚拟机性能的旋钮选项
. 调试选项   主要用来开启跟踪,打印和输出虚拟机信息

行为选项

选项和默认值描述(中英对照)
-XX:-AllowUserSignalHandlersDo not complain if the application installs signal handlers. (Relevant to Solaris and Linux only.)
如果应用程序安装了信号处理器则不抱怨(只在solaris和linux上有效)
-XX:AltStackSize=16384Alternate signal stack size (in Kbytes). (Relevant to Solaris only, removed from 5.0.)
改变信号栈大小(以千字节为单位)。(只在上solaris上有效,已经从jdk5.0中移除)
-XX:-DisableExplicitGCDisable calls to System.gc(), JVM still performs garbage collection when necessary.
禁止调用Sytem.gc()方法,虚拟机依然在必要的时候执行垃圾回收
-XX:+FailOverToOldVerifierFail over to old verifier when the new type checker fails. (Introduced in 6.)
当新的类型检查器失败时使用老的验证器(jdk6引进)
-XX:+HandlePromotionFailureThe youngest generation collection does not require a guarantee of full promotion of all live objects. (Introduced in 1.4.2 update 11) [5.0 and earlier: false.]
新生代垃圾回收没有保证所有的存活对象迁移到老生代( 1.4.2 update 11引进).jdk5及老版本的默认值是false

-XX:+MaxFDLimitBump the number of file descriptors to max. (Relevant  to Solaris only.)
把文件描述符的数量调到最大(只在solaris上有效)
-XX:PreBlockSpin=10Spin count variable for use with -XX:+UseSpinning. Controls the maximum spin iterations allowed before entering operating system thread synchronization code. (Introduced in 1.4.2.)
在-XX:+UseSpinning选项中设置的spin数目变量。控制在进入操作系统线程同步代码前夫人最大spin迭代个数。(1.4.2引进)
-XX:-RelaxAccessControlCheckRelax the access control checks in the verifier. (Introduced in 6.)
放松访验证器的问控制检查(jdk 6引进)
-XX:+ScavengeBeforeFullGCDo young generation GC prior to a full GC. (Introduced in 1.4.1.)
在直接fullGC前执行新生代GC(minor GC)(jdk 1.4.1引进)
-XX:+UseAltSigsUse alternate signals instead of SIGUSR1 and SIGUSR2 for VM internal signals. (Introduced in 1.3.1 update 9, 1.4.1. Relevant to Solaris only.)
使用替代信号取代SIGUSR1 和 SIGUSR2作为虚拟机内部信号(在jdk1.3.1 更新9和1.4.1中引进。只在solaris上有效)
-XX:+UseBoundThreadsBind user level threads to kernel threads. (Relevant to Solaris only.)
绑定用户级别的线程到内核线程。(只在solaris上有效)
-XX:-UseConcMarkSweepGCUse concurrent mark-sweep collection for the old generation. (Introduced in 1.4.1)
老生代使用并发 标记-扫除(cms)垃圾回收算法.(jdk1.4.1引进)
-XX:+UseGCOverheadLimitUse a policy that limits the proportion of the VM's time that is spent in GC before an OutOfMemory error is thrown. (Introduced in 6.)
在内存不够错误抛出之前使用一个策略来限制花在垃圾回收的时间的比例(jdk6引入)
-XX:+UseLWPSynchronizationUse LWP-based instead of thread based synchronization. (Introduced in 1.4.0. Relevant to Solaris only.)
使用基于LWP( lightweight processes欲了解请参考 http://java.sun.com/docs/hotspot/threads/threads.html)的同步替代基于线程的同步。(jdk1.4.0引入,只在solaris上有效)
-XX:-UseParallelGCUse parallel garbage collection for scavenges. (Introduced in 1.4.1)
使用并行垃圾回收算法来进行垃圾回收(jdk1.4.1引进)
-XX:-UseParallelOldGCUse parallel garbage collection for the full collections. Enabling this option automatically sets -XX:+UseParallelGC. (Introduced in 5.0 update 6.)
使用并发垃圾回收算法来进行full GC.激活这个选项自动设置了-XX:+UseParallelGC选项
-XX:-UseSerialGCUse serial garbage collection. (Introduced in 5.0.)
使用串行垃圾回收(jdk5.0引进)
-XX:-UseSpinningEnable naive spinning on Java monitor before entering operating system thread synchronizaton code. (Relevant to 1.4.2 and 5.0 only.) [1.4.2, multi-processor Windows platforms: true]
在进入操作系统线程同步锁前在java monitor上使用naive spinning
-XX:+UseTLABUse thread-local object allocation (Introduced in 1.4.0, known as UseTLE prior to that.) [1.4.2 and earlier, x86 or with -client: false]
使用本地线程对象分配策略(jdk1.4.0引进,之前的版本使用 UseTLE选项)
[1.4.2之前版本,x86硬件体系或者client模式,默认值是false]

XX+UseSplitVerifierUse the new type checker with StackMapTable attributes. (Introduced in 5.0.)[5.0: false]
使用新的拥有StackMapTable 属性的类型检查器(jdk1.5.0引进)[5.0默认值是false]

-XX:+UseThreadPrioritiesUse native thread priorities.
使用本地线程优先级
-XX:+UseVMInterruptibleIOThread interrupt before or with EINTR for I/O operations results in OS_INTRPT. (Introduced in 6. Relevant to Solaris only.)
在I/O操作之前或者与I/O操作的同时有线程中断则产生OS_INTRPT(在jdk6引进,只在Solaris 有效)


Garbage First (G1) 垃圾回收选项

选项和默认值描述(中英对照)
-XX:+UseG1GCUse the Garbage First (G1) Collector
使用G1垃圾收集器
-XX:MaxGCPauseMillis=nSets a target for the maximum GC pause time. This is a soft goal, and the JVM will make its best effort to achieve it.
设定一个最大GC停顿时间。这是一个软性目标,虚拟机会尽力达到。
-XX:InitiatingHeapOccupancyPercent=n Percentage of the (entire) heap occupancy to start a concurrent GC cycle. It is used by GCs that trigger a concurrent GC cycle based on the occupancy of the entire heap, not just one of the generations (e.g., G1). A value of 0 denotes 'do constant GC cycles'. The default value is 45.
启动一个并发垃圾收集周期所需要达到的整堆占用比例。这个比例是指整个堆的占用比例而不是某一个代(例如G1),如果这个值是0则代表‘持续做GC’。默认值是45
-XX:NewRatio=nRatio of new/old generation sizes. The default value is 2.
新生代/老生代大小的比率。默认值是2
-XX:SurvivorRatio=nRatio of eden/survivor space size. The default value is 8.
伊登区/幸存区空间大小比率。默认值是8
-XX:MaxTenuringThreshold=nMaximum value for tenuring threshold. The default value is 15.
成熟阀值最大值(控制对象最多能经历多少次Minor GC才晋升到旧生代)。默认最大值。
-XX:ParallelGCThreads=nSets the number of threads used during parallel phases of the garbage collectors. The default value varies with the platform on which the JVM is running.
设置垃圾回收器并行阶段最多使用的线程数。默认值随着jvm运行的平台的不同而变化
-XX:ConcGCThreads=nNumber of threads concurrent garbage collectors will use. The default value varies with the platform on which the JVM is running.
并发垃圾回收器所使用的线程数目。默认值随着jvm运行的平台的不同而变化
-XX:G1ReservePercent=n Sets the amount of heap that is reserved as a false ceiling to reduce the possibility of promotion failure. The default value is 10.
设置保留用来做假天花板以减少晋升(新生代对象晋升到老生代)失败可能性的堆数目。默认值是10
-XX:G1HeapRegionSize=n With G1 the Java heap is subdivided into uniformly sized regions. This sets the size of the individual sub-divisions. The default value of this parameter is determined ergonomically based upon heap size. The minimum value is 1Mb and the maximum value is 32Mb.
使用G1垃圾回收器,java堆被划分成统一大小的区块。这个选项设置每个区块的大小。默认值根据堆大小而定。最小值是1Mb,最大值是32Mb




性能选项

选项和默认值描述(中英对照)
-XX:+AggressiveOptsTurn on point performance compiler optimizations that are expected to be default in upcoming releases. (Introduced in 5.0 update 6.)
打开poing perfermance comipler优化,这个选项在接下来的发布版本中默认开启(在jdk5更新6中引进
-XX:CompileThreshold=10000Number of method invocations/branches before compiling [-client: 1,500]
编译前的方法调用/分支数目[client模式默认值1500]
-XX:LargePageSizeInBytes=4mSets the large page size used for the Java heap. (Introduced in 1.4.0 update 1.) [amd64: 2m.]
设置java堆的大页大小(1.4.0更新1引进)[amd64处理器默认值2m]
-XX:MaxHeapFreeRatio=70Maximum percentage of heap free after GC to avoid shrinking.
最大的GC后的空闲堆比例以避免收缩
-XX:MaxNewSize=sizeMaximum size of new generation (in bytes). Since 1.4, MaxNewSize is computed as a function of NewRatio. [1.3.1 Sparc: 32m; 1.3.1 x86: 2.5m.]
最大的新生代(以字节为单位)
-XX:MaxPermSize=64mSize of the Permanent Generation.  [5.0 and newer: 64 bit VMs are scaled 30% larger; 1.4 amd64: 96m; 1.3.1 -client: 32m.]
永久代的大小
-XX:MinHeapFreeRatio=40Minimum percentage of heap free after GC to avoid expansion.
最小的空间堆比例以避免膨胀

-XX:NewRatio=2Ratio of new/old generation sizes. [Sparc -client: 8; x86 -server: 8; x86 -client: 12.]-client: 4 (1.3) 8 (1.3.1+), x86: 12]
新生代/老生代大小比率
-XX:NewSize=2mDefault size of new generation (in bytes) [5.0 and newer: 64 bit VMs are scaled 30% larger; x86: 1m; x86, 5.0 and older: 640k]
新生代的默认大小(以字节为单位)
-XX:ReservedCodeCacheSize=32mReserved code cache size (in bytes) - maximum code cache size. [Solaris 64-bit, amd64, and -server x86: 48m; in 1.5.0_06 and earlier, Solaris 64-bit and amd64: 1024m.]
保留的代码缓存大小(以字节为单位)-最大的代码缓存大小
-XX:SurvivorRatio=8Ratio of eden/survivor space size [Solaris amd64: 6; Sparc in 1.3.1: 25; other Solaris platforms in 5.0 and earlier: 32]
伊登区/幸存区空间大小比率
-XX:TargetSurvivorRatio=50Desired percentage of survivor space used after scavenge.
垃圾回收后想要达到的幸存区的使用比例
-XX:ThreadStackSize=512Thread 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.]
线程栈大小(以千字节为单位)。(0代表使用默认栈大小)
-XX:+UseBiasedLockingEnable biased locking. For more details, see thistuning example. (Introduced in 5.0 update 6.) [5.0: false]
使用偏向锁。具体细节,参考tuning example
-XX:+UseFastAccessorMethodsUse optimized versions of Get<Primitive>Field.
使用优化的Get<Primitive>Field版本
-XX:-UseISMUse Intimate Shared Memory. [Not accepted for non-Solaris platforms.] For details, see Intimate Shared Memory.
使用隐私共享内存[非solaris平台不能使用]。具体细节,请参考Intimate Shared Memory.
-XX:+UseLargePagesUse large page memory. (Introduced in 5.0 update 5.) For details, see Java Support for Large Memory Pages.
使用大页内存。具体细节,请参考Java Support for Large Memory Pages.
-XX:+UseMPSSUse Multiple Page Size Support w/4mb pages for the heap. Do not use with ISM as this replaces the need for ISM. (Introduced in 1.4.0 update 1, Relevant to Solaris 9 and newer.) [1.4.1 and earlier: false]
堆使用使用多种页大小支持w/4mb。不要与ISM同时使用,因为这个替换了ISM的需求
-XX:+UseStringCacheEnables caching of commonly allocated strings.
使用缓存经常分配的字符串机制
 
-XX:AllocatePrefetchLines=1Number 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.
在使用JIT生成的预读取指令分配对象后读取的缓存行数。如果上次分配的对象是一个实例则默认值是1,如果是一个数组则是3
 
-XX:AllocatePrefetchStyle=1Generated 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.
  预读取指令的生成代码风格
0- 无预读取指令生成
1-在每次分配后执行预读取命令
2-当预读取指令执行后使用TLAB()分配水印指针来找回入口
-XX:+UseCompressedStringsUse a byte[] for Strings which can be represented as pure ASCII. (Introduced in Java 6 Update 21 Performance Release) 
使用字节数组表示能用纯ascII码表示的字符串
 
-XX:+OptimizeStringConcatOptimize String concatenation operations where possible. (Introduced in Java 6 Update 20) 
可能的场景下优化字符串拼接操作
 


调试选项

选项和默认值描述(中英对照)
-XX:-CITimePrints time spent in JIT Compiler. (Introduced in 1.4.0.) 
打印花在JIT(just in time)编译器上的时间
-XX:ErrorFile=./hs_err_pid<pid>.logIf an error occurs, save the error data to this file. (Introduced in 6.)
如果错误发生,把错误数据保存到这个文件
-XX:-ExtendedDTraceProbesEnable performance-impacting dtrace probes. (Introduced in 6. Relevant to Solaris only.)
使用影响性能的dtrace探针(jdk6引进,只对solaris有效)
-XX:HeapDumpPath=./java_pid<pid>.hprofPath to directory or filename for heap dump.Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.)
指定导出堆信息到一个文件夹或者文件,可在运行时修改的参数。
-XX:-HeapDumpOnOutOfMemoryErrorDump heap to file when java.lang.OutOfMemoryError is thrown. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.)
当内存不够错误抛出的时候导出对信息到一个文件。可在运行时修改的参数。
-XX:OnError="<cmd args>;<cmd args>"Run user-defined commands on fatal error. (Introduced in 1.4.2 update 9.)
在发生致命错误时运行用户定义的命令
-XX:OnOutOfMemoryError="<cmd args>; 
<cmd args>"
Run user-defined commands when an OutOfMemoryError is first thrown. (Introduced in 1.4.2 update 12, 6)
当内存不够错误第一次抛出的时候运行用户定义的命令
-XX:-PrintClassHistogramPrint a histogram of class instances on Ctrl-Break.Manageable. (Introduced in 1.4.2.) The jmap -histocommand provides equivalent functionality.
当按住ctrl+break时打印一个类实例柱状图。可在运行时修改的参数。
jmap-hosto命令提供等价的功能
-XX:-PrintConcurrentLocksPrint java.util.concurrent locks in Ctrl-Break thread dump. Manageable. (Introduced in 6.) The jstack -lcommand provides equivalent functionality.
在用ctrl+break到处线程栈信息的时候打印java.util.concurrent 锁信息。可在运行时修改的参数。jstak-l命令提供等价的功能
-XX:-PrintCommandLineFlagsPrint flags that appeared on the command line. (Introduced in 5.0.)
打印命令行上出现的额标志信息
-XX:-PrintCompilationPrint message when a method is compiled.
当一个方法被编译的时候打印信息。
-XX:-PrintGCPrint messages at garbage collection. Manageable.
垃圾回收的时候打印信息。可在运行时修改的参数。
-XX:-PrintGCDetailsPrint more details at garbage collection.Manageable. (Introduced in 1.4.0.)
垃圾回收的时候打印更多详细信息。可在运行时修改的参数。
-XX:-PrintGCTimeStampsPrint timestamps at garbage collection. Manageable(Introduced in 1.4.0.)
在垃圾回收的时候打印时间信息。可在运行时修改的参数。
-XX:-PrintTenuringDistributionPrint tenuring age information.
打印成熟度信息
-XX:-TraceClassLoadingTrace loading of classes.
跟踪类加载
-XX:-TraceClassLoadingPreorderTrace all classes loaded in order referenced (not loaded). (Introduced in 1.4.2.)
按引用顺序跟踪所有类加载顺序
-XX:-TraceClassResolutionTrace constant pool resolutions. (Introduced in 1.4.2.)
跟踪常量词容量
-XX:-TraceClassUnloadingTrace unloading of classes.
跟踪卸载类
-XX:-TraceLoaderConstraintsTrace recording of loader constraints. (Introduced in 6.)
跟踪记录加载器限制
-XX:+PerfSaveDataToFileSaves jvmstat binary data on exit.
在退出的时候保存虚拟机状态二进制数据
-XX:ParallelGCThreads=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.
设置在新生代和老生并行垃圾收集器的线程数。默认值随着虚拟机运行的不同而变化
-XX:+UseCompressedOopsEnables 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.
在堆大小小于32gb的64位机上使用压缩的指针(对象引用使用32位替代64位指针)来
-XX:+AlwaysPreTouchPre-touch the Java heap during JVM initialization. Every page of the heap is thus demand-zeroed during initialization rather than incrementally during application execution.
在jvm初始化的时候提前接触java堆。这样堆的每一页都在初始化的时候按照要求清零而不是增量的在应用执行的时候
-XX: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.
设置对象分配的预取大小。即将写入新对象的内存以离上次分配的对象的距离的这个大小被预取到缓存(以位为单位)。每个java线程有自己的分配点。默认值随着虚拟机运行的平台而变化
-XX: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.
内联一个上次编译过的方法,且仅当它产生的本地代码大小比这个小。默认值随着虚拟机运行的平台而变化
-XX:MaxInlineSize=35Maximum bytecode size of a method to be inlined.
一个方法能被内联的最大字节码大小
-XX: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.
能被内联的经常的执行的方法的最大字节码大小。默认值随着虚拟机运行的平台而变化
-XX:LoopUnrollLimit=Unroll loop bodies with server compiler intermediate representation node count less than this value. The limit used by the server compiler is a function of this value, not the actual value. The default value varies with the platform on which the JVM is running.
使用服务器编译器作为媒介表示循环次数,如果循环次数小于这个次数则展开循环体
-XX:InitialTenuringThreshold=7Sets the initial tenuring threshold for use in adaptive GC sizing in the parallel young collector. The tenuring threshold is the number of times an object survives a young collection before being promoted to the old, or tenured, generation.
为自适应GC并行新生代收集器设置初始的tensuring阀值。tensuring阀值是一个对象在进入老生代前在新生代存活的次数
-XX:MaxTenuringThreshold=Sets the maximum tenuring threshold for use in adaptive GC sizing. The current largest value is 15. The default value is 15 for the parallel collector and is 4 for CMS.
设置最大的
tensu阀值ing阀值,以在自适应GC。目前的最大值是15.并行收集器默认值是15,cms是4

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值