Eric 发布的文章

JVM HPROF 笔记

HPROF is a tool for heap and CPU profiling shipped with every JDK release. It is a dynamic-link library (DLL) that interfaces with the Java Virtual Machine (JVM) using the Java Virtual Machine Tool Interface (JVM TI). The tool writes profiling information either to a file or to a socket in ASCII or binary format. This information can be further processed by a profiler front end tool.

The HPROF tool is capable of presenting CPU usage, heap allocation statistics, and monitor contention profiles. In addition, it can report complete heap dumps and states of all the monitors and threads in the JVM. In terms of diagnosing problems, HPROF is useful when analyzing performance, lock contention, memory leaks, and other issues.

JVM Troubleshooting 学习笔记

Java Platform, Standard Edition Troubleshooting Guide

Command-line options that are prefixed with -XX are specific to Java HotSpot VM. For more information about command-line options used by Java HotSpot VM, see Java HotSpot VM Command-Line Options.
The jcmd is a new JDK profiling utility in JDK 8. It is suggested to use the latest diagnostic utility, jcmd instead of the earlier jstack, jinfo, and jmap utilities.

JVM - jstat

Monitors Java Virtual Machine (JVM) statistics. This command is experimental and unsupported.

jstat [ generalOption | outputOptions vmid [ interval[s|ms] [ count ] ]
//vmid: [protocol:][//]lvmid[@hostname[:port]/servername]

refer: https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jstat.html

JVM - jcmd

The jcmd utility is used to send diagnostic command requests to the JVM, where these requests are useful for controlling Java Flight Recordings, troubleshoot, and diagnose JVM and Java Applications. It must be used on the same machine where the JVM is running, and have the same effective user and group identifiers that were used to launch the JVM.
 Sample
 jcmd
 jcmd <process id/main class> PerfCounter.print
 jcmd 2125 help //2125 is the pid
 jcmd 2125 GC.heap_dump filename=Myheapdump
 jcmd 2125 VM.uptime
 jcmd <process id/main class> VM.system_properties
 jcmd <process id/main class> VM.flags
 jcmd MyProgram help Thread.print
 jcmd <process id/main class> Thread.print
 jcmd <process id/main class> [options]
 jcmd 7060 JFR.start name=MyRecording settings=profile delay=20s duration=2m filename=C:\TEMP\myrecording.jfr
 jcmd 7060 JFR.check
 jcmd 7060 JFR.stop
More:
jcmd man page: https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jcmd.html
Useful Commands for jcmd Utility: https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html#BABEJDGE
Troubleshoot with jcmd Utility: https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html#BABFFIFA

JVM - jps

Lists the instrumented Java Virtual Machines (JVMs of HotSpot) on the target system. This command is experimental and unsupported.
 A jstatd process is assumed to be running on the target host.
 The jps command uses the Java launcher to find the class name and arguments passed to the main method. If the target JVM is started with a custom launcher, then the class or JAR file name and the arguments to the main method are not available. In this case, the jps command outputs the string Unknown for the class name or JAR file name and for the arguments to the main method.
 The command only lists the JVMs for which the principle has access rights as determined by operating system-specific access control mechanisms.
 Sample
 jps
 jps –l remote.domain
 jps –m remote.domain:2002 (see jstatd –n)

Refer: https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jps.html