# JVM Internals with JCMD: Inspecting Tomcat and ORDS Processes

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:
    

```plaintext
jcmd ${PID} {command}
```

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

```plaintext
jcmd ${PID} VM.flags
```

Or to view the VM system properties:

```plaintext
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.
    

```plaintext
jcmd ${PID} VM.version
```

* **VM.flags**: Displays the VM flags and their values.
    

```plaintext
jcmd ${PID} VM.flags
```

* **VM.system\_properties**: Lists all system properties.
    

```plaintext
jcmd ${PID} VM.system_properties
```

* **VM.command\_line**: Shows the command-line options passed to the JVM.
    

```plaintext
jcmd ${PID} VM.command_line
```

* **GC.heap\_info**: Provides information about heap memory usage.
    

```plaintext
jcmd ${PID} GC.heap_info
```

* **GC.class\_histogram**: Prints a histogram of the number of instances of each class.
    

```plaintext
jcmd ${PID} GC.class_histogram
```

* [**GC.run**](http://GC.run): Initiates garbage collection.
    

```plaintext
jcmd ${PID} GC.run
```

* **Thread.print**: Prints stack traces for all threads.
    

```plaintext
jcmd ${PID} Thread.print
```

* **VM.native\_memory**: Prints information about native memory usage.
    

```plaintext
jcmd ${PID} VM.native_memory
```

* **VM.uptime**: Displays the uptime of the JVM.
    

```plaintext
jcmd ${PID} VM.uptime
```

---
