Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the parameters of a running JVM

Tags:

java

jvm

Is there a way to get the parameters of a running JVM?

Is there a command-line tool, like jstat, which takes as input the PID of the JVM and returns its starting parameters? I am particularly interested in the -Xmx and -Xms values that were given when starting the JVM.

To clarify my constraints for the JVM, we would like to check if it is running on a production server. That's why we prefer the minimum disruption. We are able to monitor the JVM using jstat, and so we hope there's a similar simple solution to access the parameters.

We also tried to get the parameters using jvisualvm. But in order to connect to a remote jvm, we need to run jstatd and modify the security settings of the JVM, which we found to be very disruptive and risky on a production server.

like image 691
H-H Avatar asked Mar 15 '11 19:03

H-H


People also ask

What are the JVM parameters?

JVM has four types of GC implementations: Serial Garbage Collector. Parallel Garbage Collector. CMS Garbage Collector.

Where are JVM parameters set?

You can change the parameters passed to the JVM in the Arguments tab in the VM Arguments box. That configuration can then be used as the default when running the project.

Where can I find JVM options?

options configuration file. The default location of this file is config/jvm. options (when installing from the tar or zip distributions) and /etc/elasticsearch/jvm. options (when installing from the Debian or RPM packages).

What is JVM command line?

Description. The java command starts a Java application. It does this by starting the Java Virtual Machine (JVM), loading the specified class, and calling that class's main() method. The method must be declared public and static , it must not return any value, and it must accept a String array as a parameter.


1 Answers

You can use jps like:

jps -lvm 

It prints something like:

4050 com.intellij.idea.Main -Xms128m -Xmx512m -XX:MaxPermSize=250m -ea -Xbootclasspath/a:../lib/boot.jar -Djb.restart.code=88 4667 sun.tools.jps.Jps -lvm -Dapplication.home=/opt/java/jdk1.6.0_22 -Xms8m 
like image 75
Peter Lawrey Avatar answered Sep 20 '22 08:09

Peter Lawrey