jcmd is a promising tool regrouping utilities of jmap, jsp, etc...
You can find introduction and man page but still it's very light.
On the web, I found apparently existing commands like GC.heap_info, that I've never been able to use for my tests.
Some of these commands need special flags. -XX:NativeMemoryTracking=detail
will give you VM.native_memory
command, for instance.
But for some others it's not clear how to activate them or if it depends of the jdk version, etc..
I can't even find an exhaustive list of existing command.
Any info?
Edit Thx to @apangin response, I've started to compute a short summary of available commands by jvm version.
Disclaimer : it comes from code teardown only, not real test
jdk8
- help
- VM.uptime [options]
- VM.flags [options]
- VM.system_properties
- VM.command_line
- VM.version
- VM.native_memory [options]
- VM.check_commercial_features
- VM.unlock_commercial_features
- Thread.print [options]
- GC.run
- GC.run_finalization
- GC.rotate_log
- GC.class_stats [options]
- GC.class_histogram [options]
- GC.heap_dump [options]
- ManagementAgent.start_local
- ManagementAgent.start [options]
- ManagementAgent.stopJFR.start [options]
- JFR.stop [options]
- JFR.dump [options]
- JFR.check [options]
jdk9
only the additional
- VM.set_flag [options]
- VM.info
- VM.class_hierarchy [options]
- VM.dynlibs
- VM.print_touched_methods
- JVMTI.data_dump
- JVMTI.agent_load [options]
- GC.finalizer_info
- GC.heap_info
- ManagementAgent.status
- ManagementAgent.stop
- Compiler.queue
- Compiler.codelist
- Compiler.codecache
- Compiler.directives_print
- Compiler.directives_remove
- Compiler.directives_add [options]
- Compiler.directives_clear
Basing on @EricWang's answer, HotSpot diagnostic command sources and the personal experience, I've created the full list of
jcmd
commands available in JDK 8u121 with the additional details about requirements etc.help [options] [<command name>]
For more information about a specific command use
help <command>
. With no argument this will show a list of available commands.help -all
will show help for all commands.VM.uptime [options]
Print VM uptime.
VM.flags [options]
Print VM flag options and their current values.
VM.system_properties
Print system properties.
VM.command_line
Print the command line used to start this VM instance.
VM.version
Print JVM version information.
VM.native_memory [options]
Print native memory usage.
-XX:NativeMemoryTracking=[summary|detail]
VM.check_commercial_features
Display status of commercial features.
VM.unlock_commercial_features
Unlock commercial features.
Thread.print [options]
Print all threads with stacktraces.
GC.run
Call java.lang.System.gc().
GC.run_finalization
Call java.lang.System.runFinalization().
GC.rotate_log
Force the GC log file to be rotated.
-Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num>
GC.class_stats [options] [<columns>]
Provide statistics about Java class meta data.
-XX:+UnlockDiagnosticVMOptions
GC.class_histogram [options]
Provide statistics about the Java heap usage.
GC.heap_dump [options] <filename>
Generate a HPROF format dump of the Java heap.
-all
option is specified.ManagementAgent.start_local
Start local management agent.
ManagementAgent.start [options]
Start remote management agent.
ManagementAgent.stop
Stop remote management agent.
JFR.start [options]
Starts a new JFR recording
-XX:+UnlockCommercialFeatures
JFR.stop [options]
Stops a JFR recording
-XX:+UnlockCommercialFeatures
JFR.dump [options]
Copies contents of a JFR recording to file. Either the name or the recording id must be specified.
-XX:+UnlockCommercialFeatures
JFR.check [options]
Checks running JFR recording(s)
-XX:+UnlockCommercialFeatures
jcmd
itself provides such information when applied on a specific Java process, and optionally a specific sub command.How to get help:
jps
orjcmd -l
, if you don't know the pid of target java process yet, (e.g I will take java process with pid 8976 as example in subsequent steps).help
sub command on a specific java process, e.gjcmd 8976 help
, it will list available sub commands for the process.jcmd 8976 help Thread.print
, it will print help ofThread.print
sub command.jcmd 8976 Thread.print
orjcmd 8976 Thread.print | less -N
By the way, just as you mentioned, following link describes jcmd command briefly: https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html