Hotspot JVM 参数总结

我对JavaHotspot

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

JavaHotSpotVMOptions

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

JVM选项不严格的被分为三类:

1.Behavioraloptions,用以改变VM的基本行为.

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

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

可管理标记的使用:

1.BooleanOptions:

-XX:+表示打开

-XX:-表示关闭

2.Numericoptions

-XX:=.数字需包括'm'or'M'代表单位megabytes,'k'or'K'代表单位kilobytes,'g'or'G'代表单位gigabytes,例如forexample,32k

与32768代表同一值32x1024.

3.Stringoptions

-XX:=,通常用来声明logpath.

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

BehavioralOptions

-XX:-DisableExplicitGC

关闭调用System.gc()方法,但是JVM还是会在需要的时候进行fullGC.

-XX:+ScavengeBeforeFullGC

在MajorGC之前进行一次MinorGC

-XX:-UseConcMarkSweepGC

对TenuredGeneration使用CMS(concurrentmark-sweepcollection)算法.

-XX:-UseParallelGC

YoungGeneration使用Parallel算法,TenuredGeneration使用Serial算法.

-XX:-UseParallelOldGC

在FullGC中使用ParallelGC算法

-XX:-UseSerialGC

使用YoungOld带均使用Serial算法

PerformanceOptions

-XX:LargePageSizeInBytes=size

为javaheap设置pagesize

-XX:MinHeapFreeRatio=40

在GC之后最小的空闲heap占总heap的比例MinimumpercentageofheapfreeafterGCtoavoidexpansion.

-XX:MaxHeapFreeRatio=70

设置在GC之后,最大的空闲heap占总heap的比例

-XX:MaxNewSize=size

设置NewGeneration最大值.

-XX:MaxPermSize=size

设置PermGeneration的大小.

-XX:NewRatio=n

n=new/oldgenerationsizes

-XX:NewSize=2.125m

newgeneration的默认值

-XX:TargetSurvivorRatio=50

回收后survior区的期望比例

DebuggingOptions

-XX:HeapDumpPath=

设置HeapDum存储路径

-XX:-HeapDumpOnOutOfMemoryError

在OOM时生成heapdump文件.

-XX:OnOutOfMemoryError=";

用户自定义命令,在OutOfMemoryError抛出时运行定义命令.

-XX:-PrintGC

打印GC时的信息

-XX:-PrintGCDetails

打印GC时的详细信息

-XX:-PrintGCTimeStamps

打印GC的时间戳

-XX:-PrintTenuringDistribution

打印Tenured区的信息

-XX:ParallelGCThreads=

设置ParallelGarbageCollector的thread数量

-XX:MaxTenuringThreshold=

设置控制对象从新生代转移到到旧生代的MinorGC次数

----------------------------------------------------------------------------------------------------

[

-XX:-TraceClassLoadingTraceloadingofclasses.

-XX:-TraceClassLoadingPreorderTraceallclassesloadedinorder

referenced(notloaded).(Introducedin1.4.2.XX:-TraceClassResolution

Traceconstantpoolresolutions.(Introducedin1.4.2.)

-XX:-TraceClassUnloading

Traceunloadingofclasses.

-XX:-TraceLoaderConstraints

Tracerecordingofloaderconstraints.(Introducedin6.)

-XX:+PerfSaveDataToFile

Savesjvmstatbinarydataonexit.

-XX:+UseCompressedOops

Enablestheuseofcompressedpointers(objectreferencesrepresentedas

32bitoffsetsinsteadof64-bitpointers)foroptimized64-bit

performancewithJavaheapsizeslessthan32gb.

-XX:+AlwaysPreTouch

Pre-touchtheJavaheapduringJVMinitialization.Everypageofthe

heapisthusdemand-zeroedduringinitializationratherthan

incrementallyduringapplicationexecution.

-XX:AllocatePrefetchDistance=

Setstheprefetchdistanceforobjectallocation.Memoryabouttobe

writtenwiththevalueofnewobjectsisprefetchedintocacheatthis

distance(inbytes)beyondtheaddressofthelastallocatedobject.

EachJavathreadhasitsownallocationpoint.Thedefaultvaluevaries

withtheplatformonwhichtheJVMisrunning.

-XX:InlineSmallCode=I

Inlineapreviouslycompiledmethodonlyifitsgeneratednativecode

sizeislessthanthis.Thedefaultvaluevarieswiththeplatformon

whichtheJVMisrunning.

-XX:MaxInlineSize=35

Maximumbytecodesizeofamethodtobeinlined.

-XX:FreqInlineSize=

Maximumbytecodesizeofafrequentlyexecutedmethodtobeinlined.ThedefaultvaluevarieswiththeplatformonwhichtheJVMisrunning.

-XX:LoopUnrollLimit=

Unrollloopbodieswithservercompilerintermediaterepresentationnodecountlessthanthisvalue.Thelimitusedbytheservercompilerisafunctionofthisvalue,nottheactualvalue.ThedefaultvaluevarieswiththeplatformonwhichtheJVMisrunning.

-XX:InitialTenuringThreshold=7

SetstheinitialtenuringthresholdforuseinadaptiveGCsizingintheparallelyoungcollector.Thetenuringthresholdisthenumberoftimesanobjectsurvivesayoungcollectionbeforebeingpromotedtotheold,ortenured,generation.

-XX:-PrintClassHistogram

PrintahistogramofclassinstancesonCtrl-Break.Manageable.

(Introducedin1.4.2.)Thejmap-histocommandprovidesequivalent

functionality.

-XX:-PrintConcurrentLocks

Printjava.util.concurrentlocksinCtrl-Breakthreaddump.Manageable.

(Introducedin6.)Thejstack-lcommandprovidesequivalent

functionality.

-XX:-PrintCommandLineFlags

Printflagsthatappearedonthecommandline.(Introducedin5.0.)

-XX:-PrintCompilation

Printmessagewhenamethodiscompiled.

]

jvm

相关推荐