这一篇说一下JVM 参数相关,首先JVM参数中包含着么几类 标准参数(Standard)、非标准参数(Non-Standard)、高级运行时选项、JIT相关编译高级选项、适用性高级选项、GC相关高级参数、不建议使用的参数(可能会被弃用) 后续会对每个系列的参数还有使用技巧进行详细的剖析,这一篇仅仅是个引导。 但是这个系列,对于不感兴趣的同学可能会无聊至极。不过掌握一些技巧还是蛮有趣的。 懂原理,才能更好的使用嘛~ 其中 标准参数:开头直接为参数名、 非标准参数: -X 开头 高级选项:-XX:开头 后跟+为开启,-为关闭 下面是具体的参数: 大家可以对应这个参数列表对应自己看着感兴趣的看看使用,或者检查一下自己了解哪些。 标准参数(Standard): -agentlib:libname -agentpath:pathname -client -Dproperty=value -d32 -d64 -disableassertions[:[packagename]…|:classname] -da[:[packagename]…|:classname] -disablesystemassertions -dsa -enableassertions[:[packagename]…|:classname] -ea[:[packagename]…|:classname] -enablesystemassertions -esa -help -? -jar filename -javaagent:jarpath[=options] -jre-restrict-search -no-jre-restrict-search -server -showversion -splash:imgname -verbose:class -verbose:gc -verbose:jni -version -version:release 这类标准参数,作用信息非常明确,而且大都有具体的选项。会放在最后介绍。 非标准参数(Non-Standard): -X -XBatch -Xbootclasspath:path -Xbootclasspath/a:path -Xbootclasspath/p:path -Xcheck:jni -Xcomp -Xdebug -Xdiag -Xfuture -Xint -Xinternalversion -Xloggc:filename -Xmaxjitcodesize=size -Xmixed -Xmnsize -Xmssize -Xmxsize -Xnoclassgc -Xprof -Xrs -Xshare:(mode、auto、on、off、dump) -XshowSettings:(category、all、locale、properties、vm) -Xsssize -Xusealtsigs -Xverify:(mode、remote、all、none) 这一块儿会首先说明,因为我们日常用的频次高的大部分是这一片参数
高级运行时选项(Advanced Runtime Options): -XX:+CheckEndorsedAndExtDirs -XX:+DisableAttachMechanism -XX:ErrorFile=filename -XX:+FailOverToOldVerifier -XX:+FilghtRecorder -XX:-FilghtRecorder -XX:FilghtRecorderOptions={ parameter=value、 defaultrecording={true|false}、 disk={true|false}、 dumponexit={true|false}、 dumponexitpath=path、 globalbuffersize=size loglevel={quiet|error|warning|info|debug|trace} maxage=time maxchunksize=size maxsize=size repository=path samplethreads={true|false} settings=path stackdepth=depth threadbuffersize=size } -XX:LargePageSizeInBytes=size -XX:MaxDirectMemorySize=size -XX:NativeMemoryTracking={ mode、off、summary、detail } -XX:ObjectAlignmentInBytes=alignment -XX:OnError=string -XX:OnOutOfMemoryError=string -XX:+PerfDataSaveToFile -XX:+PrintCommandLineFlags -XX:+PrintNMTStatistics -XX:+RelaxAccessControlCheck -XX:+ResourceManagement -XX:ResourceManagementSampleInterval=value (milliseconds) -XX:SharedArchiveFile=path -XX:SharedClassListFile=file_name -XX:+ShowMessageBoxOnError -XX:StartFlightRecording={ parameter=value、 compress={true|false}、 defaultrecording={true|false}、 delay=time、 dumponexit={true|false}、 duration=time、 filename=path、 name=identifier、 maxage=time、 maxsize=size、 settings=path } -XX:ThreadStackSize=size -XX:+TraceClassLoading -XX:+TraceClassLoadingPreorder -XX:+TraceClassResolution -XX:+TraceClassUnloading -XX:+TraceLoaderConstraints -XX:+UnlockCommercialFeatures -XX:+UseAltSigs -XX:+UseAppCDS -XX:-UseBiasedLocking -XX:-UseCompressedOops -XX:+UseHugeTLBFS -XX:+UseLargePages -XX:+UseMembar -XX:+UsePerfData -XX:+UseTransparentHugePages -XX:+AllowUserSignalHandlers
JIT相关编译高级选项 Advanced JIT Compiler Options
-XX:+AggressiveOpts -XX:AllocateInstancePrefetchLines=lines -XX:AllocatePrefetchDistance=size -XX:AllocatePrefetchInstr=instruction -XX:AllocatePrefetchLines=lines -XX:AllocatePrefetchStepSize=size -XX:AllocatePrefetchStyle=style -XX:+BackgroundCompilation -XX:CICompilerCount=threads -XX:CodeCacheMinimumFreeSpace=size -XX:CompileCommand=command,method[,option(break、compileonly、dontinline、exclude、help、inline、log、option、print、quiet)] -XX:CompileCommandFile=filename -XX:CompileOnly=methods -XX:CompileThreshold=invocations -XX:+DoEscapeAnalysis -XX:InitialCodeCacheSize=size -XX:+Inline -XX:InlineSmallCode=size -XX:+LogCompilation -XX:MaxInlineSize=size -XX:MaxNodeLimit=nodes -XX:MaxTrivialSize=size -XX:+OptimizeStringConcat -XX:+PrintAssembly -XX:+PrintCompilation -XX:+PrintInlining -XX:ReservedCodeCacheSize=size -XX:RTMAbortRatio=abort_ratio -XX:RTMRetryCount=number_of_retries -XX:-TieredCompilation -XX:+UseAES -XX:+UseAESIntrinsics -XX:+UseCodeCacheFlushing -XX:+UseCondCardMark -XX:+UseRTMDeopt -XX:+UseRTMLocking -XX:+UseSHA -XX:+UseSHA1Intrinsics -XX:+UseSHA256Intrinsics -XX:+UseSHA512Intrinsics -XX:+UseSuperWord
适用性高级选项 Advanced Serviceability Options -XX:+ExtendedDTraceProbes -XX:+HeapDumpOnOutOfMemory -XX:HeapDumpPath=path -XX:LogFile=path -XX:+PrintClassHistogram -XX:+PrintConcurrentLocks -XX:+UnlockDiagnosticVMOptions
GC相关高级参数 Advanced Garbage Collection Options -XX:+AggressiveHeap -XX:+AlwaysPreTouch -XX:+CMSClassUnloadingEnabled -XX:CMSExpAvgFactor=percent -XX:CMSInitiatingOccupancyFraction=percent -XX:+CMSScavengeBeforeRemark -XX:CMSTriggerRatio=percent -XX:ConcGCThreads=threads -XX:+DisableExplicitGC -XX:+ExplicitGCInvokesConcurrent -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses -XX:G1HeapRegionSize=size -XX:+G1PrintHeapRegions -XX:G1ReservePercent=percent -XX:InitialHeapSize=size -XX:InitialSurvivorRatio=ratio -XX:InitiatingHeapOccupancyPercent=percent -XX:MaxGCPauseMillis=time -XX:MaxHeapSize=size -XX:MaxHeapFreeRatio=percent -XX:MaxMetaspaceSize=size -XX:MaxNewSize=size -XX:MaxTenuringThreshold=threshold -XX:MetaspaceSize=size -XX:MinHeapFreeRatio=percent -XX:NewRatio=ratio -XX:NewSize=size -XX:ParallelGCThreads=threads -XX:+ParallelRefProcEnabled -XX:+PrintAdaptiveSizePolicy -XX:+PrintGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTaskTimeStamps -XX:+PrintGCTimeStamps -XX:+PrintStringDeduplicationStatistics -XX:+PrintTenuringDistribution -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=time -XX:StringDeduplicationAgeThreshold=threshold -XX:SurvivorRatio=ratio -XX:TargetSurvivorRatio=percent -XX:TLABSize=size -XX:+UseAdaptiveSizePolicy -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseConcMarkSweepGC -XX:+UseG1GC -XX:+UseGCOverheadLimit -XX:+UseNUMA -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseParNewGC -XX:+UseSerialGC -XX:+UseSHM -XX:+UseStringDeduplication -XX:+UseTLAB
不建议使用的参数 Deprecated and Removed Options -Xincgc -Xrunlibname -XX:CMSIncrementalDutyCycle=percent -XX:CMSIncrementalDutyCycleMin=percent -XX:+CMSIncrementalMode -XX:CMSIncrementalOffset=percent -XX:+CMSIncrementalPacing -XX:CMSIncrementalSafetyFactor=percent -XX:CMSInitiatingPermOccupancyFraction=percent -XX:MaxPermSize=size -XX:PermSize=size -XX:+UseSplitVerifier -XX:+UseStringCache