Print all Oracle hotspot JVM parameters and their default values (Hotspot JVM options/flags)

Source: Internet
Author: User

Java Programmers sometimes need to understand JVM-related parameters, either out of curiosity or work needs. Some parameters are listed in the Oracle document (Click here). Not all parameters are listed, and some parameters are enabled or disabled by default, in some cases, setting a parameter does not take effect. Sometimes you want JVM to do something, but you don't know which parameter can be used. The following describes some methods to list all parameters, so that you have a clear goal in your research or Google.

If you want to check whether the online running JVM has set those parameters and what takes effect, you may use the following methods:

1. Use the ps command in Linux to find the parameters used to start a Java application.

ps -ef | grep "your java app name"

This command will display all the parameters passed to the Java command when you start the Java application. You can see the JVM parameters in it.

2. Check the startup script or parameter configuration.

You may not be able to find all the places where this JVM parameter is set.

Generally, the above two methods must be familiar with or familiar with JVM, at least specific parameters.

In fact, the JVM has a parameter-XX: + printflagsfinal, which can print almost all JVM-supported parameters and their default values. If you want to check whether your Java application uses those parameters, you just need to add this parameter at startup.

1. view the parameters supported by your JDK.

java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version

2. Print JVM parameters enabled for Java applications

java -XX:+PrintFlagsFinal -classpath=/path/to/your/libs MainClass

3. If your Java application is already running, you cannot use the jinfo tool to check whether a JVM parameter has taken effect.For example, the well-known G1 garbage collector is not started by default in jdk7update3 in both client and server (-server) mode.

Jinfo is released along with JDK. Use JPs to find the Java application PID first. Run jinfo directly to view the instructions.

jinfo -flag UseParallelOldGC 31072
-XX:+UseParallelOldGC

There are still many tools used in JDK. You can try every command in the $ {java_home}/bin directory one by one.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.