Chinaunix首页 | 论坛 | 博客
  • 博客访问: 766853
  • 博文数量: 160
  • 博客积分: 2516
  • 博客等级: 大尉
  • 技术积分: 1511
  • 用 户 组: 普通用户
  • 注册时间: 2004-10-24 17:58
文章分类

全部博文(160)

文章存档

2019年(2)

2018年(3)

2017年(15)

2016年(3)

2015年(11)

2014年(3)

2013年(1)

2012年(3)

2011年(17)

2010年(25)

2009年(17)

2008年(13)

2007年(14)

2006年(21)

2005年(10)

2004年(2)

分类: Java

2010-07-08 18:02:11

JAVA HOTSPOT VM参数大全

(JDK版本6.0)

SUN的JDK版本从1.3.1开始使用HotSpot虚拟机技术。

HotSpot是较新的Java虚拟机技术,用来代替JIT(Just in Time)技术,可以大大提高Java运行的性能。

Java原先是把源代码编译为字节码在虚拟机执行,这样执行速度较慢。而该技术将常用的部分代码编译为本地(原生,native)代码,这样

显著提高了性能。

用于服务器版和标准版的HotSpot有所不同。

其他的Java虚拟机也有类似的技术。

HotSpot JVM 参数可以分为标准参数(standard options)和非标准参数(non-standard options)。
标准参数相对稳定,在JDK未来的版本里不会有太大的改动。
非标准参数则有因升级JDK而改变的可能。


标准参数:
-client
  使用Java HotSpot 客户端版VM。

-server
  使用Java HotSpot 服务器版VM。如果是64位的JDK,默认只有server版,所以以上两个参数对64位版本JDK无效。

-agentlib: libname [=options]
  加载本地代理函数库, e.g.
  -agentlib:jdwp=help

-agentpath :pathname [=options]
  使用给定的路径加载本地代理库。

-classpath classpath
-cp classpath
  不用说了。

-Dproperty =value
  设置一个系统属性。

-d32
-d64

  要求程序在32位或64位下跑,未来这个参数可能有变。

-enableassertions [:"..." | : ]
-ea [:"..." | : ]
  开启断言。

-disableassertions [:"..." | : ]
-da [:"..." | : ]
  关闭断言。

-enablesystemassertions
-
esa
  启动所有系统类的断言。


-disablesystemassertions
-dsa

  关闭所有系统类的断言。

-jar
  这个也没什么说的。

-javaagent :jarpath [=options]
  加载Java 程序语言代理

-verbose:class
  输出每个加载的类详细信息。

-verbose:gc
  输出GC的详细信息。

-verbose:jni
  输出本地方法接口的调用信息。

-version
-help
-?

  不用说了。

-X
  显示可用的非标准参数



非标准参数:

-Xint
  以解释模式运行。JVM不会使用HotSpot的新特性,不会将部分常用代码编译为本地代码,所有代码都以字节码的方式解释运行。你可以理解为使用JDK1.3.1以前的JIT方式运行程序。

-Xbatch
  不使用后台编译。

-Xbootclasspath:bootclasspath
  使用bootstrap classloader 加载指定路径的class或jar,这是种完全覆盖默认系统类加载的方案,慎用。

-Xbootclasspath/a:bootclasspath
  将指定的classpath追加到默认的bootclasspath的后面加载

-Xbootclasspath/p:bootclasspath
  将指定的classpath追加到默认的bootclasspath的前面加载

-Xcheck:jni
  在调用JNI函数时做额外的检查。这个参数会降低JVM的执行性能。

-Xfuture
  执行严格的class文件格式检查,不加这个参数,默认使用JDK1.1.* 版本的class格式检查方法。

-Xnoclassgc
  禁用class垃圾收集。

-Xincgc
  开启增量垃圾收集机制。默认为关闭。增量垃圾收集能减少因垃圾收集而引起的程序中断,它会在程序运行期间不定期地以并发的方式运行,在运行期间不会引起中断但是会减少分配给程序的cpu资源。

-Xloggc:file
  GC详情日志。效果如-verbose:gc ,不过这个可以输出到一个文件。除了-verbose:gc包含的信息,还有显示发生的时间。 文件可以是远程的,但是考虑到网络延迟会引起JVM中断,一般建议使用本地文件,

-Xms
  分配的堆空间初始值:
  -Xms6291456
  -Xms6144k
  -Xms6m

-Xmx
  分配的堆空间最大值:
  -Xmx83886080
  -Xmx81920k
  -Xmx80m

-Xprof
  在运行程序时给出分析数据。适用于开发环境,不适用于生产环境。

-Xrs
  减少JVM的操作系统信号的使用量。

-Xss
  线程栈内存。


非标准-XX参数

 

有三种-XX参数的形式:

 

  • Boolean 型的参数 开启如 -XX:+
  • Numeric 型参数 -XX:
  • String 参数 -XX:

以下是-XX参数列表,本来想都翻译过来,但是发现一些技术术语如果硬是翻译可能会导致词不达意,因此大部分描述都保持原文。

 

 

参数名和默认值
描述
-XX:-AllowUserSignalHandlers 允许使用用户自定义的信号处理器 (只对应Solaris和Linux)
-XX:AltStackSize=16384 修改栈容量 (单位 Kb) (对应Solaris, JDK 5.0以后弃用)
-XX:-DisableExplicitGC 禁止手动调用System.gc()
-XX:+FailOverToOldVerifier 如果新的类型校验器验证失败使用旧版本的类型校验器 (开始于JDK6.)
-XX:+HandlePromotionFailure The 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.]
-XX:+MaxFDLimit 将文件描述符加到最大 (对应Solaris)
-XX:PreBlockSpin=10 Spin 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:-RelaxAccessControlCheck 放宽类型校验机的准入控制(JDK6)
-XX:+ScavengeBeforeFullGC 在full GC之前先做年轻代GC (开始于JDK1.4.1.)
-XX:+UseAltSigs Use 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.)
-XX:+UseBoundThreads Bind user level threads to kernel threads. (Relevant to Solaris only.)
-XX:-UseConcMarkSweepGC 使用并发的mark-sweep GC收集年老代 (始于JDK1.4.1)
-XX:+UseGCOverheadLimit 使用一种限制VM做GC操作的时间所占比例过高的策略 (始于JDK6.)
-XX:+UseLWPSynchronization 使用轻量级进程同步替代线程同步 (始于JDK1.4.0. Solaris相关)
-XX:-UseParallelGC 使用并发平行GC(始于JDK1.4.1)
-XX:-UseParallelOldGC 使用并发平行GC做 full GC. (始于JDK5.0 update 6.)
-XX:-UseSerialGC 使用串行GC (始于JDK5.0.)
-XX:-UseSpinning Enable 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]
-XX:+UseTLAB Use 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]
-XX:+UseSplitVerifier Use the new type checker with StackMapTable attributes. (Introduced in 5.0.)[5.0: false]
-XX:+UseThreadPriorities Use native thread priorities.
-XX:+UseVMInterruptibleIO Thread interrupt before or with EINTR for I/O operations results in OS_INTRPT. (Introduced in 6. Relevant to Solaris only.)

 

 

 

参数名和默认值 描述
-XX:+AggressiveOpts Turn on point performance compiler optimizations that are expected to be default in upcoming releases. (Introduced in 5.0 update 6.)

-XX:CompileThreshold=10000 Number of method invocations/branches before compiling [-client: 1,500]

-XX:LargePageSizeInBytes=4m Sets the large page size used for the Java heap. (Introduced in 1.4.0 update 1.) [amd64: 2m.]

-XX:MaxHeapFreeRatio=70 Maximum percentage of heap free after GC to avoid shrinking.

-XX:MaxNewSize=size Maximum 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=64m Size 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=40 Minimum percentage of heap free after GC to avoid expansion.

-XX:NewRatio=2 Ratio 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=2.125m Default 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=32m Reserved 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 and64: 1024m.]

-XX:SurvivorRatio=8 Ratio 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=50 Desired percentage of survivor space used after scavenge.

-XX:ThreadStackSize=512 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.]

-XX:+UseBiasedLocking Enable biased locking. For more details, see this . (Introduced in 5.0 update 6.) [5.0: false]

-XX:+UseFastAccessorMethods Use optimized versions of GetField.

-XX:-UseISM Use Intimate Shared Memory. [Not accepted for non-Solaris platforms.] For details, see .

-XX:+UseLargePages Use large page memory. (Introduced in 5.0 update 5.) For details, see .

-XX:+UseMPSS Use 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]

-XX:+StringCache Enables caching of commonly allocated strings.

-XX:AllocatePrefetchLines=1 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.

-XX: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.

 

 

参数名和默认值 描述
-XX:-CITime Prints time spent in JIT Compiler. (Introduced in 1.4.0.)

-XX:ErrorFile=./hs_err_pid.log If an error occurs, save the error data to this file. (Introduced in 6.)

-XX:-ExtendedDTraceProbes Enable performance-impacting probes. (Introduced in 6. Relevant to Solaris only.)

-XX:HeapDumpPath=./java_pid.hprof Path to directory or filename for heap dump. Manageable . (Introduced in 1.4.2 update 12, 5.0 update 7.)

-XX:-HeapDumpOnOutOfMemoryError Dump heap to file when java.lang.OutOfMemoryError is thrown. Manageable . (Introduced in 1.4.2 update 12, 5.0 update 7.)

-XX:OnError=";" Run user-defined commands on fatal error. (Introduced in 1.4.2 update 9.)

-XX:OnOutOfMemoryError=";
"
Run user-defined commands when an OutOfMemoryError is first thrown. (Introduced in 1.4.2 update 12, 6)

-XX:-PrintClassHistogram Print a histogram of class instances on Ctrl-Break. Manageable . (Introduced in 1.4.2.) The command provides equivalent functionality.

-XX:-PrintConcurrentLocks Print java.util.concurrent locks in Ctrl-Break thread dump. Manageable . (Introduced in 6.) The command provides equivalent functionality.

-XX:-PrintCommandLineFlags Print flags that appeared on the command line. (Introduced in 5.0.)

-XX:-PrintCompilation Print message when a method is compiled.

-XX:-PrintGC Print messages at garbage collection. Manageable .

-XX:-PrintGCDetails Print more details at garbage collection. Manageable . (Introduced in 1.4.0.)

-XX:-PrintGCTimeStamps Print timestamps at garbage collection. Manageable (Introduced in 1.4.0.)

-XX:-PrintTenuringDistribution Print tenuring age information.

-XX:-TraceClassLoading Trace loading of classes.

-XX:-TraceClassLoadingPreorder Trace all classes loaded in order referenced (not loaded). (Introduced in 1.4.2.)

-XX:-TraceClassResolution Trace constant pool resolutions. (Introduced in 1.4.2.)

-XX:-TraceClassUnloading Trace unloading of classes.

-XX:-TraceLoaderConstraints Trace recording of loader constraints. (Introduced in 6.)

-XX:+PerfSaveDataToFile Saves jvmstat binary data on exit.

 

 

 

 

参考:

阅读(1737) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~