Hotspot JVM 参数总结

我对Java Hotspot 
VM的部分翻译,有些在工作中完全没有用到的参数我没有做解释,原文章在这 
Java HotSpot VM Options 

同时,在工作中有一些没有接触到的参数,我不打清楚其含义跟作用, 也请了解的朋友留言赐教.这些Option我贴在了文章最后面. 

JVM 选项不严格的被分为三类: 
1.Behavioral options, 用以改变VM的基本行为. 

2.Performance tuning options,影响VM的重要参数,对其进行调整进行性能调优. 

3.Debug Options,用来在log中进行跟踪,打印一些VM信息. 

可管理标记的使用: 

1.Boolean Options: 

-XX:+  表示打开 

-XX:-  表示关闭 

2.Numeric options 
-XX:=. 数字需包括'm' or 'M'代表单位megabytes, 'k' or 'K'代表单位 kilobytes,'g' or 'G' 代表单位 gigabytes,例如 for example, 32k 
与32768代表同一值 32x1024. 

3.String options 
-XX:=,通常用来声明 log path. 

罗列一些常用参数极其代表含义: 

Behavioral Options 

-XX:-DisableExplicitGC 
关闭调用System.gc()方法, 但是JVM还是会在需要的时候进行full GC. 

-XX:+ScavengeBeforeFullGC 
在Major GC 之前 进行一次 Minor GC 

-XX:-UseConcMarkSweepGC 
对 Tenured Generation 使用 CMS(concurrent mark-sweep collection)算法. 

-XX:-UseParallelGC 
Young Generation使用Parallel算法,Tenured Generation 使用 Serial算法.

-XX:-UseParallelOldGC 
在Full GC 中使用 Parallel GC 算法 

-XX:-UseSerialGC 
使用Young Old 带均使用Serial算法 

Performance Options 

-XX:LargePageSizeInBytes=size 
为java heap 设置page size 

-XX:MinHeapFreeRatio=40 
在GC之后 最小的空闲heap占总heap的比例Minimum percentage of heap free after GC to avoid expansion. 

-XX:MaxHeapFreeRatio=70 
设置在GC之后, 最大的空闲heap占总heap的比例 

-XX:MaxNewSize=size 
设置 New Generation最大值. 

-XX:MaxPermSize=size 
设置Perm Generation的大小. 

-XX:NewRatio=n 
n = new/old generation sizes 

-XX:NewSize=2.125m 
new generation的默认值 

-XX:TargetSurvivorRatio=50 
回收后survior区的期望比例 

Debugging Options 

-XX:HeapDumpPath=
设置Heap Dum 存储路径 

-XX:-HeapDumpOnOutOfMemoryError 
在OOM时生成heapdump文件. 

-XX:OnOutOfMemoryError="; 
用户自定义命令, 在OutOfMemory Error抛出时运行定义命令. 

-XX:-PrintGC 
打印GC时的信息 

-XX:-PrintGCDetails 
打印GC时的详细信息 

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

-XX:-PrintTenuringDistribution 
打印Tenured区的信息 

-XX:ParallelGCThreads= 
设置Parallel Garbage Collector的thread 数量 

-XX:MaxTenuringThreshold= 
设置控制对象从新生代转移到到旧生代的Minor GC次数 
---------------------------------------------------------------------------------------------------- 

[ 
-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. 

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

-XX:+AlwaysPreTouch 
Pre-touch the Java heap during JVM initialization. Every page of the 
heap is thus demand-zeroed during initialization rather than 
incrementally during application execution. 

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

-XX:InlineSmallCode= I 
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=35 
Maximum bytecode size of a method to be inlined. 

-XX:FreqInlineSize= 
Maximum bytecode size of a frequently executed method to be inlined. Thedefault 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=7 
Sets the initial tenuring threshold for use in adaptive GC sizing in the parallel young collector. The tenuring threshold is the number of timesan object survives a young collection before being promoted to the old,or tenured, generation. 

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

-XX:-PrintConcurrentLocks 
Print java.util.concurrent locks in Ctrl-Break thread dump. Manageable. 
(Introduced in 6.) The jstack -l 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. 
] 

转自:http://relaxbod.iteye.com/blog/1294530

你可能感兴趣的:(java,jvm)