JVM Internals with JCMD: Inspecting Tomcat and ORDS Processes

Exploring the powerful JCMD utility for monitoring Java web applications.

·

2 min read

Properly configured Java Virtual Machine (JVM) settings are crucial for the performance and stability of Java web applications like Apache Tomcat and Oracle REST Data Services (ORDS). Here's a quick overview on leveraging the JCMD utility to troubleshoot and resolve JVM configuration problems in these platforms. By exploring various JCMD commands, you'll gain insights into memory usage, garbage collection, and other JVM metrics, enabling you to identify and fix configuration issues proactively.

  1. Locate the Process ID (PID): First, you need to find out the process ID of your Tomcat or ORDS instance. You can do this by using tools like ps (on Unix-based systems) or Task Manager (on Windows) or any other process monitoring tool you prefer.

  2. Use jcmd command: Once you have the PID, you can use jcmd to view JVM details. The general syntax is:

jcmd ${PID} {command}

For example, to view the VM flags, you would use:

jcmd ${PID} VM.flags

Or to view the VM system properties:

jcmd ${PID} VM.system_properties

Replace ${PID} with the process ID of your Tomcat instance and {command} with the specific command you want to execute.


There are several useful jcmd commands for diagnosing and monitoring a Java process such as Tomcat. Here are some commonly used ones:

  • VM.version: Displays the version information of the JVM.
jcmd ${PID} VM.version
  • VM.flags: Displays the VM flags and their values.
jcmd ${PID} VM.flags
  • VM.system_properties: Lists all system properties.
jcmd ${PID} VM.system_properties
  • VM.command_line: Shows the command-line options passed to the JVM.
jcmd ${PID} VM.command_line
  • GC.heap_info: Provides information about heap memory usage.
jcmd ${PID} GC.heap_info
  • GC.class_histogram: Prints a histogram of the number of instances of each class.
jcmd ${PID} GC.class_histogram
  • GC.run: Initiates garbage collection.
jcmd ${PID} GC.run
  • Thread.print: Prints stack traces for all threads.
jcmd ${PID} Thread.print
  • VM.native_memory: Prints information about native memory usage.
jcmd ${PID} VM.native_memory
  • VM.uptime: Displays the uptime of the JVM.
jcmd ${PID} VM.uptime