In-depth understanding of java virtual machine --- virtual machine tool jinfo (15)

Function: View and adjust virtual machine parameters in real time.

jinfo is a tool that comes with jdk. It can be used to view the extended parameters of the running java application (parameters marked with -X in the JVM); it even supports modifying some parameters at runtime.

1. You can see which flags in the JVM can be dynamically modified by jinfo by running the following command:

[html]  view plain copy  
 
  1. # java -XX:+PrintFlagsFinal -version|grep manageable  
  2.      intx CMSAbortablePrecleanWaitMillis            = 100             {manageable}          
  3.      intx CMSWaitDuration                           = 2000            {manageable}          
  4.      bool HeapDumpAfterFullGC                       = false           {manageable}          
  5.      bool HeapDumpBeforeFullGC                      = false           {manageable}          
  6.      bool HeapDumpOnOutOfMemoryError                = false           {manageable}          
  7.     ccstr HeapDumpPath                              =                 {manageable}          
  8.     uintx MaxHeapFreeRatio                          = 100             {manageable}          
  9.     uintx  MinHeapFreeRatio =  0 {manageable}          
  10.      bool PrintClassHistogram                       = false           {manageable}          
  11.      bool PrintClassHistogramAfterFullGC            = false           {manageable}          
  12.      bool PrintClassHistogramBeforeFullGC           = false           {manageable}          
  13.      bool PrintConcurrentLocks                      = false           {manageable}          
  14.      bool PrintGC                                   = false           {manageable}          
  15.      bool PrintGCDateStamps                         = false           {manageable}          
  16.      bool PrintGCDetails                            = false           {manageable}          
  17.      bool PrintGCTimeStamps                         = false           {manageable}          
  18. java version "1.7.0_79"  
  19. Java(TM) SE Runtime Environment (build 1.7.0_79-b15)  
  20. Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)  

 

All JVM flags can be listed through the option -XX:+PrintFlagsFinal, and the flag marked manageable is the part worthy of our attention. These flags can be dynamically modified through the JDK management interface (-XX:+PrintFlagsFinal).

Usage summary:

Introduction

jinfo is a command that comes with jdk, which can be used to view the extended parameters of a running Java application, and even supports modifying some parameters at runtime.

Usually, jps is used to view the id of the java process, and then jinfo is used to view the jvm information of the specified pid.

jps #View the current running state of the virtual machine process through jps

View the parameters of the jvm

1
jinfo -flags process_id

View java system parameters

1
jinfo -sysprops process_id

These parameters of the virtual machine can be viewed with the following command:

1
java -XX:+PrintFlagsFinal -version | grep manageable

In addition to setting parameters through the startup script, PrintGC is turned on by default, so we only need to turn on the PrintGCDetails parameter.

1
2
jinfo -flag +PrintGC 27250
jinfo -flag +PrintGCDetails 27250

If you need to turn off the printing of the GC log, use the following command:

1
2
jinfo -flag -PrintGC 27250
jinfo -flag -PrintGCDetails 27250 

Check whether the printing of the GC log is enabled:

1
2
jinfo -flag PrintGC 27250
jinfo -flag PrintGCDetails 27250  

Common JVM parameters

1
2
3
4
5
6
7
-Xms:初始堆大小,默认为物理内存的1/64(<1GB);默认(MinHeapFreeRatio参数可以调整)空余堆内存小于40%时,JVM就会增大堆直到-Xmx的最大限制
-Xmx:最大堆大小,默认(MaxHeapFreeRatio参数可以调整)空余堆内存大于70%时,JVM会减少堆直到 -Xms的最小限制
-Xmn:新生代的内存空间大小,注意:此处的大小是(eden+ 2 survivor space)。与jmap -heap中显示的New gen是不同的。整个堆大小=新生代大小 + 老生代大小 + 永久代大小。在保证堆大小不变的情况下,增大新生代后,将会减小老生代大小。此值对系统性能影响较大,Sun官方推荐配置为整个堆的3/8。
-XX:SurvivorRatio:新生代中Eden区域与Survivor区域的容量比值,默认值为8。两个Survivor区与一个Eden区的比值为2:8,一个Survivor区占整个年轻代的1/10。
-Xss:每个线程的堆栈大小。JDK5.0以后每个线程堆栈大小为1M,以前每个线程堆栈大小为256K。应根据应用的线程所需内存大小进行适当调整。在相同物理内存下,减小这个值能生成更多的线程。但是操作系统对一个进程内的线程数还是有限制的,不能无限生成,经验值在3000~5000左右。一般小的应用, 如果栈不是很深, 应该是128k够用的,大的应用建议使用256k。这个选项对性能影响比较大,需要严格的测试。和threadstacksize选项解释很类似,官方文档似乎没有解释,在论坛中有这样一句话:"-Xss  is  translated  in  a VM flag named ThreadStackSize”一般设置这个值就可以了。
-XX:PermSize:设置永久代(perm gen)初始值。默认值为物理内存的1/64。
-XX:MaxPermSize:设置持久代最大值。物理内存的1/4。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325396370&siteId=291194637