This series of notes is mainly based on "in-depth understanding of the Java Virtual Machine: JVM advanced features and best practices 2nd Edition" is a book of reading notes.
How to view JVM run-time parameters for online JVM tuning it is critical, because only know JVM parameters currently used what value, in order to know how to tune.
The following parameters JVM, can be used to print the JVM runtime parameters and their values:
parameter | Explanation |
---|---|
-XX:+PrintFlagsInitial | View the initial value |
-XX:+PrintFlagsFinal | View the final value as the initial value may be modified |
-XX:+UnlockExperimentalVMOptions | Unlock experimental parameters, JVM in some experimental parameters can not be directly assigned, you must use this parameter to assign |
-XX:+UnlockDiagnosticVMOptions | Unlock diagnostic parameters |
-XX:+PrintCommandLineFlags | Print command-line parameters |
For example, use the command to view the JVM parameters PrintFlagsFinal
java -XX:+PrintFlagsFinal -version
Section outputs as follows:
Where "="
it represents the initial value ":="
represents the value after the modification.
This is the command to view the execution java
command of the current process, the official use, we usually see is the Java program process line, then, will be used JDK command line tools: jps
and jinfo
.
All JDK tools are available in the official website of Oracle Java Tools Reference find use in the documentation, which is the main reference.
jps
JDK comes with some command-line tools, and Linux jps command ps, are viewing the process, but only to view the Java process jps.
格式:jps [ options ] [ hostid ]
View jps
help information:
Use jps
the command to view the local Java process:
The output of Bootstrap
the Tomcat process, you can use the jps -l
output to confirm that the package path:
Use jps -v
View more of parameters:
jinfo
jinfo command to view the configuration of the JVM.
格式:
jinfo [ option ] pid
jinfo [ option ] executable core
jinfo [ option ] [ servier-id ] remote-hostname-or-IP
View jinfo
help information:
Use jinfo -flag [参数] [pid]
to view the maximum Java heap:
See if the G1 or Parallel collector:
Use jinfo -flags [pid]
View all modified parameter values:
to sum up
First through the jps
find command to view the Java process, then use the jinfo
command you can see when you specify the parameters for running Java programs.