Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

jcmd helps you make JVM tuning decisions by collecting evidence from a running Java process; it does not provide universal tuning flags or guarantee a performance improvement. Identify the correct process, check which commands its JVM supports, choose a diagnostic suited to the question, and weigh the operational impact before collecting data.

What jcmd does—and what tuning still requires

Oracle describes jcmd as a utility for sending diagnostic command requests to a JVM. It can expose heap information, class-level heap statistics, thread stacks, heap dumps, and Java Flight Recorder (JFR) data. These observations can inform a tuning decision, but they do not determine the right change for every application.

Use the evidence in the context of the workload you are investigating. For example, a heap snapshot alone does not establish that an application has a memory leak; the symptom, workload, and behavior over time matter too.

Find the JVM and check its command support

  1. List visible Java processes: run jcmd -l. It lists visible Java PIDs, main classes, and launch arguments.
  2. Locate containerized processes if needed: Oracle notes that JVMs running in a separate Docker process may not appear in jcmd -l. Use a process-listing tool such as ps to find the PID.
  3. Confirm the target: verify the PID and application before requesting diagnostics.
  4. Check commands on that exact JVM: run jcmd <pid> help to see available commands, then jcmd <pid> help <command> for a command’s syntax and options. Support varies by target runtime, so do not assume a command documented for a different JDK is available.

Run jcmd on the same machine as the target JVM and with the same effective user and group identifiers used to launch it. If an argument contains spaces, enclose it in shell quotes. See Oracle’s JDK 24 jcmd command reference for command syntax and impact notes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a command for the question you need to answer

Question jcmd command What to consider
What general heap information is available? GC.heap_info A diagnostic snapshot, not proof of a leak.
Which classes account for heap use? GC.class_histogram Oracle labels this command high impact; impact depends on heap size and contents.
What objects are in the heap for offline analysis? GC.heap_dump High impact. It creates an HPROF file and may request a full GC unless -all is used. Plan storage and access to the resulting file.
What are threads doing now? Thread.print The amount of output depends on the number of threads.
How can thread stacks be saved for later review? Thread.dump_to_file Supports plain-text or JSON output.
What happens over a diagnostic time window? JFR.start, JFR.check, JFR.dump, and JFR.stop Confirm availability with the target JVM’s help. Recording settings affect collected data and overhead.

For JFR command details and diagnostic guidance, consult Oracle’s JDK 24 diagnostic tools guide. The impact labels are operational guidance, not a promise of identical cost on every JVM; heap size and contents can affect the impact of heap operations.

Capture thread or time-based evidence

Take a thread dump

After confirming the target JVM supports the command, use jcmd <pid> Thread.print to print thread stacks. To save stacks for later analysis, inspect the syntax for Thread.dump_to_file with jcmd <pid> help Thread.dump_to_file; the command supports plain-text and JSON output.

Start and manage a JFR recording

Use JFR.start to begin a recording, JFR.check to inspect recording status, JFR.dump to write recording data, and JFR.stop to stop it. Check the target JVM’s help for supported options and syntax before starting. Select settings that suit the question and diagnostic window, since they affect both the data collected and recording overhead.

Use heap diagnostics deliberately

Start with GC.heap_info when you need general heap information. If you need class-level statistics, GC.class_histogram provides a more detailed view but is marked high impact. A heap dump is a larger step: GC.heap_dump writes an HPROF file, can be high impact, and may request a full GC unless -all is used.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Consider the diagnostic’s impact against the production workload and timing.
  • For a heap dump, plan where the HPROF file will be written, how much storage is available, and who can access it.
  • Use a snapshot as evidence to investigate, not as a standalone conclusion about a leak or the cause of poor performance.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Turn observations into a tuning decision

Use the diagnostic that matches the symptom: heap commands for heap questions, thread commands for stack state, and JFR for behavior across a time window. Compare what you observe with the application’s workload and the problem you are trying to solve before changing JVM configuration. Oracle’s command and troubleshooting documentation describes diagnostic operations and their impact; it does not prescribe a universal tuning sequence or establish a guaranteed performance result.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.