Common command-line tools for JVM tuning

JPS: JVM Process Status Tool

Vm process status tool

You can list running VM processes and display the name of the vm execution main class and the unique local VM ids (LVMids) of these processes.

jstat: JVM Statistics Monitoring Tool

Monitor vm statistics

A command line tool used to monitor the running status of VMS. It can display running data such as class information, memory, garbage collection, JIT compilation, and so on in local or remote virtual machine processes (requiring RMI support from the remote host). On servers with no GUI and only plain text console environment, it is the preferred tool for locating virtual machine performance problems at run time.

jinfo: Configuration Info for Java

Java configuration information tool

You can view and adjust VM parameters in real time. You can run the -v command of the JPS command to view the list of parameters that are explicitly specified when the VM is started. If you want to know the default values of parameters that are not explicitly specified, you can use the -flag option of jinfo to query. Jinfo can also print out the contents of system.getProperties () for the virtual machine process using the -sysprops option.

jmap: Memory Map for Java

Java Memory Image tool for generating heapdump snapshots of virtual machines (heapdump files)

Jmap does more than just get dump files. It can also query Finalize execution queues, Java heaps, and persistent generation details, such as space usage, which collector is currently in use, etc. Like JInfo, many of jMap’s features are limited on Windows, except that the -dump option for generating dump files and the -histo option for viewing instances of each class and space usage statistics are available on all operating systems. The remaining options are available only on Linux and Solaris.

jhat: JVM Heap Dump Browser

For analyzing heapdump files, it sets up an HTTP/HTML server that allows users to view the analysis results in a browser

jstack: Stack Trace forJava

Java stack trace tool

This command is used to generate a thread snapshot of the vm at the current time. A thread snapshot is a stack of methods being executed by each thread in the current VIRTUAL machine.

The purpose of creating a thread snapshot is to locate the cause of a thread’s long pause, such as deadlock between threads, dead loop, and long wait caused by requesting external resources. By looking at the call stack of each thread when it pauses, you can see what the unresponsive thread is doing in the background, or what resources it is waiting for.