`
BabyDuncan
  • 浏览: 574816 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

JVM的五个比较有用的命令

 
阅读更多

1.DisableExplicitGC

手动调用System.gc() 是一个危险的操作。

使用-XX:+DisableExplicitGC标志自动将System.gc()调用转换成一个空操作,为您提供运行代码的机会。

 

2.HeapDumpOnOutOfMemoryError

-XX:+HeapDumpOnOutOfMemoryError可以完成在JVM消亡之际捕获堆的一个快照,并可以根据-XX:HeapDumpPath标志指定到保存文件的实际路径,这样就可以分析jvm出现OutOfMemory情况的时候出现的问题以及原因了。

 

3.bootclasspath

-Xbootclasspath使您可以设置完整的引导类路径(这通常包括一个对rt.jar的引用),以及一些其他JDK附带的(不是rt.jar的一部分)JAR文件。

 

4.verbose

对于虚拟的或任何类型的Java应用程序,-verbose是一个很有用的一级诊断使用程序。该标志有三个子标志:gc、class和jni。

5.Command-line-X

运行命令行参数-X,列出JVM提供的所有非标准(但大部分都是安全的)参数

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

the -X options are non-standard and subject to change without notice.

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics