Introduction to jinfo
jinfo (Configuration Info for Java), you can view and adjust virtual machine parameters.
Official website address: https://docs.oracle.com/en/java/javase/11/tools/jinfo.html
Options | illustrate |
---|---|
no option | Output all parameters and system properties |
-flag name | output the parameter with the corresponding name |
-flag[±]name | Turns on or off the parameter of the corresponding name, only the parameter marked as manageable can be dynamically modified |
-flag name=value | Set the parameter corresponding to the name |
-flags | output all parameters |
-sysprops | output system properties |
Check
1) View the parameters obtained in System.getProperties()
jinfo -sysprops 6619
2) View some parameters that have been assigned values
jinfo -flags 7563
3) View the specific parameter values of the Java process
[root@bogon ~]# jinfo -flag UseParallelGC 12023
-XX:-UseParallelGC
[root@bogon ~]# jinfo -flag UseG1GC 12023
-XX:-UseG1GC
[root@bogon ~]# jinfo -flag MaxHeapSize 12023
-XX:MaxHeapSize=8388608
Revise
jinfo can modify some parameters while the program is running and make them take effect immediately. But not all parameters support dynamic modification. Only the flags marked as manageable can be modified in real time. This modification capability is limited.
View manageable parameters
java -XX:+PrintFlagsFinal -version | grep manageable
Modify manageable parameter values
[root@bogon ~]# jinfo -flag PrintGCDetails 12023
-XX:-PrintGCDetails
[root@bogon ~]# jinfo -flag +PrintGCDetails 12023
[root@bogon ~]# jinfo -flag PrintGCDetails 12023
-XX:+PrintGCDetails
[root@bogon ~]# jinfo -flag MaxHeapFreeRatio 12023
-XX:MaxHeapFreeRatio=70
[root@bogon ~]# jinfo -flag MaxHeapFreeRatio=90 12023
[root@bogon ~]# jinfo -flag MaxHeapFreeRatio 12023
-XX:MaxHeapFreeRatio=90
expand
View the initial values of all JVM parameters to start with
java -XX:+PrintFlagsInitial
View the final values of all JVM parameters
java -XX:+PrintFlagsFinal
View detailed parameters that have been set by the user or JVM
java -XX:+PrintCommandLineFlags