赞
踩
标准参数(-):所有的JVM实现都必须实现这些参数的功能,而且向后兼容;
非标准参数(-X):默认jvm实现这些参数的功能,但是并不保证所有jvm实现都满足,且不保证向后兼容
非稳定参数(-XX):非Stable参数,即非静态参数,此类参数各个jvm实现会有所不同,将来可能会随时取消,这些参数通常用于高级性能调优、垃圾收集器配置、堆内存大小等高级设置,如设置永久代元空间大小:
JDK7配置为:
-XX:PermSize=512m
-XX:MaxPermSize=512m
在JDK8及以上版本则不同,配置为:
-XX:MetaspaceSize=512m
-XX:MaxMetaspaceSize=512m
输入命令java -help就能获得当前机器所有java的标准参数列表,如java -version, java -jar等,除此之外还有查询GC问题常用的输出参数:
-verbose:class 输出jvm载入类的相关信息,当jvm报告说找不到类或者类冲突时可此进行诊断。
-verbose:gc 输出每次GC的相关情况。|
-verbose:jni 输出native方法调用的相关情况,一般用于诊断jni调用错误信息
bdpcloud@host154[/home/bdpcloud]$ java -help
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server,
because you are running on a server-class machine.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
Warning: this feature is deprecated and will be removed
in a future release.
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
Warning: this feature is deprecated and will be removed
in a future release.
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
输入java -X命令,能够获得当前JVM支持的所有非标准参数列表,一些常见的参数设置:
-Xms:设置初始Java堆大小
-Xmx:设置最大Java堆大小,通常最大java堆大小与初始堆大小设置为一样大,防止内存抖动,默认为服务器内存的四分之一
-Xss:设置Java线程堆栈大小
bdpcloud@host154[/home/bdpcloud]$ java -X
-Xmixed mixed mode execution (default)
-Xint interpreted mode execution only
-Xbootclasspath:<directories and zip/jar files separated by :>
set search path for bootstrap classes and resources
-Xbootclasspath/a:<directories and zip/jar files separated by :>
append to end of bootstrap class path
-Xbootclasspath/p:<directories and zip/jar files separated by :>
prepend in front of bootstrap class path
-Xdiag show additional diagnostic messages
-Xnoclassgc disable class garbage collection
-Xincgc enable incremental garbage collection
-Xloggc:<file> log GC status to a file with time stamps
-Xbatch disable background compilation
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size
-Xprof output cpu profiling data
-Xfuture enable strictest checks, anticipating future default
-Xrs reduce use of OS signals by Java/VM (see documentation)
-Xcheck:jni perform additional checks for JNI functions
-Xshare:off do not attempt to use shared class data
-Xshare:auto use shared class data if possible (default)
-Xshare:on require using shared class data, otherwise fail.
-XshowSettings show all settings and continue
-XshowSettings:all
show all settings and continue
-XshowSettings:vm
show all vm related settings and continue
-XshowSettings:system
(Linux Only) show host system or container
configuration and continue
-XshowSettings:properties
show all property settings and continue
-XshowSettings:locale
show all locale related settings and continue
The -X options are non-standard and subject to change without notice.
输入java -XX:+PrintFlagsFinal -version命令即可查看各个版本JVM的参数,可自行输出查看,一般可以将他们归为以下几个大类:
1.性能参数(Performance Options):用于JVM的性能调优和内存分配控制,如初始化内存大小的设置;
2.行为参数(Behavioral Options):用于改变JVM的基础行为,如GC的方式和算法的选择;
3.调试参数(Debugging Options):用于监控、打印、输出等jvm参数,用于显示jvm更加详细的信息;
此外,此类参数设置方法有四种:
-XX:+<option> 启用选项,一般用于行为参数,即行为参数开关开启
-XX:-<option> 不启用选项,一般用于行为参数,即行为参数开关关闭
-XX:<option>=<number> 给选项设置一个数字类型值,可跟单位,例如 32k, 1024m, 2g
-XX:<option>=<string> 给选项设置一个字符串值,例如-XX:HeapDumpPath=./dump.core
-XX:-DisableExplicitGC:禁止调用System.gc();但jvm的gc仍然有效
-XX:+UseSerialGC:启用串行GC,即采用Serial+Serial Old模式
-XX:+UseParallelGC:启用并行GC,即采用Parallel Scavenge+Serial Old收集器组合(-Server模式下的默认组合)
-XX:GCTimeRatio=99:设置用户执行时间占总时间的比例(默认值99,即1%的时间用于GC)
-XX:MaxGCPauseMillis=time:设置GC的最大停顿时间(这个参数只对Parallel Scavenge有效)
-XX:+UseParNewGC:使用ParNew+Serial Old收集器组合
-XX:ParallelGCThreads:设置执行内存回收的线程数,在+UseParNewGC的情况下使用
-XX:+UseParallelOldGC:使用Parallel Scavenge +Parallel Old组合收集器
-XX:+UseConcMarkSweepGC:使用ParNew+CMS+Serial Old组合并发收集,优先使用ParNew+CMS,当用户线程内存不足时,采用备用方案Serial Old收集。
-XX:+ScavengeBeforeFullGC:新生代GC优先于Full GC执行
-XX:NewSize=2.125m:新生代对象生成时占用内存的默认值
-XX:MaxNewSize=size:新生成对象能占用内存的最大值
-XX:MaxPermSize=64m:方法区所能占用的最大内存(非堆内存)
-XX:PermSize=64m:方法区分配的初始内存
-XX:MaxTenuringThreshold=15:对象在新生代存活区切换的次数(坚持过MinorGC的次数,每坚持过一次,该值就增加1),大于该值会进入老年代(年龄阈值)
-XX:MaxHeapFreeRatio=70:GC后java堆中空闲量占的最大比例,大于该值,则堆内存会减少
-XX:MinHeapFreeRatio=40:GC后java堆中空闲量占的最小比例,小于该值,则堆内存会增加
-XX:NewRatio=2:新生代内存容量与老生代内存容量的比例
-XX:ReservedCodeCacheSize=32m:保留代码占用的内存容量
-XX:ThreadStackSize=512:设置线程栈大小,若为0则使用系统默认值
-XX:LargePageSizeInBytes=4m:设置用于Java堆的大页面尺寸
-XX:PretenureSizeThreshold=size:大于该值的对象直接晋升入老年代(这种对象少用为好)
-XX:SurvivorRatio=8:Eden区域Survivor区的容量比值,如默认值为8,代表Eden:Survivor1:Survivor2=8:1:1
-XX:-CITime:打印消耗在JIT编译的时间
-XX:ErrorFile=./hs_err_pid<pid>.log:保存错误日志或者数据到文件中
-XX:-ExtendedDTraceProbes:开启solaris特有的dtrace探针
-XX:HeapDumpPath=./java_pid<pid>.hprof:指定导出堆信息时的路径或文件名
-XX:-HeapDumpOnOutOfMemoryError:当首次遭遇OOM时导出此时堆中相关信息
-XX:OnError="<cmd args>;<cmd args>":出现致命ERROR之后运行自定义命令
-XX:OnOutOfMemoryError="<cmd args>;<cmd args>":当首次遭遇OOM时执行自定义命令
-XX:-PrintClassHistogram:遇到Ctrl-Break后打印类实例的柱状信息,与jmap -histo功能相同
-XX:-PrintConcurrentLocks:遇到Ctrl-Break后打印并发锁的相关信息,与jstack -l功能相同
-XX:-PrintCommandLineFlags:打印在命令行中出现过的标记
-XX:-PrintCompilation:当一个方法被编译时打印相关信息
-XX:-PrintGC:每次GC时打印相关信息
-XX:-PrintGCDetails:每次GC时打印详细信息
-XX:-PrintGCTimeStamps:打印每次GC的时间戳
-XX:-TraceClassLoading:跟踪类的加载信息
-XX:-TraceClassLoadingPreorder:跟踪被引用到的所有类的加载信息
-XX:-TraceClassResolution:跟踪常量池
-XX:-TraceClassUnloading:跟踪类的卸载信息
-XX:-TraceLoaderConstraints:跟踪类加载器约束的相关信息
bdpcloud@host154[/home/bdpcloud]$ java -XX:+PrintFlagsFinal -version | more
[Global flags]
intx ActiveProcessorCount = -1 {product}
uintx AdaptiveSizeDecrementScaleFactor = 4 {product}
uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product}
uintx AdaptiveSizePausePolicy = 0 {product}
uintx AdaptiveSizePolicyCollectionCostMargin = 50 {product}
uintx AdaptiveSizePolicyInitializingSteps = 20 {product}
uintx AdaptiveSizePolicyOutputInterval = 0 {product}
uintx AdaptiveSizePolicyWeight = 10 {product}
uintx AdaptiveSizeThroughPutPolicy = 0 {product}
uintx AdaptiveTimeWeight = 25 {product}
bool AdjustConcurrency = false {product}
bool AggressiveHeap = false {product}
bool AggressiveOpts = false {product}
intx AliasLevel = 3 {C2 product}
bool AlignVector = true {C2 product}
intx AllocateInstancePrefetchLines = 1 {product}
intx AllocatePrefetchDistance = 256 {product}
intx AllocatePrefetchInstr = 3 {product}
intx AllocatePrefetchLines = 3 {product}
intx AllocatePrefetchStepSize = 64 {product}
intx AllocatePrefetchStyle = 1 {product}
bool AllowJNIEnvProxy = false {product}
bool AllowNonVirtualCalls = false {product}
bool AllowParallelDefineClass = false {product}
bool AllowUserSignalHandlers = false {product}
bool AlwaysActAsServerClassMachine = false {product}
bool AlwaysCompileL
.........................
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。