JVM-JDK command line tool, jvm-jdk command line
JDK command line tool
When we enter the/bin directory in the JDK installation directory, we will find many gadgets, including java, javac, which we are familiar with and often use, there are also a lot of unfamiliar tools that we don't use very much. next, let's take a look at some tools that are rarely used.
Jps> JVM Procrss Stauts Tool, which displays all HotSpot VM processes in the specified system.
You can list running VM processes and display the classes of the Main Class (main Class, Main () function) where the VM executes) name and the unique ID (Local Virtual Machine Identifier, LVMID) of the Local Virtual Machine of these processes ).
For local Virtual Machine processes, the LVMID and the operating system Process ID (Process Identifier, PID) are consistent.
Jps command format:
Jps [options] [hostid]
For example: (since I have not run any program, only sun. tools. jps. Jps is available)
Some common parameters:
I>-q: only the LVMID is output. The name of the main class is omitted.
II>-m: output the parameter passed to the main () function when the VM process starts.
III>-l: The full name of the output main class. If the process runs a Jar package, the output Jar path
IV>-v: output the JVM parameters when the VM process starts.
Jstat> JVM Statistics Monitoring ToolUsed to collect operation data of all aspects of the HotSpot virtual machine. it can display class loading, memory, garbage collection, JIT compilation and other running data in local or remote virtual machine processes. On servers without GUI, it only provides the class-only text Console environment, it will be the preferred tool for locating VM performance problems at runtime.
Jstat command format:
Jstat [option vmid [interval [s | MS] [count]
Note: I> if it is a local Virtual Machine Process, the VMID and LVMID are consistent.
II> interval and count indicate the query interval and number of times. If this parameter is omitted, the query is performed only once.
For example, jstat-gc 4158 300 10 indicates that 300 of the garbage collection status of the process is queried every 4158 milliseconds, and a total of 10 queries are performed.
III> optin indicates the virtual machine information that the user wants to query. It mainly consists of three categories: class loading, garbage collection, and running compiling.
Jinfo> Configuration Info for JavaDisplays virtual machine configuration information.
Jinfo command format:
Jinfo [optin] pid
Parameters:
I>-flag can be used to query the default values of unspecified parameters.
For example:
Jmap> Memory Map for Java,Generate a VM memory dump snapshot (heapdump file). You can also query the finalize execution queue, Java heap, and permanent generation details, such as space utilization, which collector is currently used, and so on.
Jmap command format:
Jmap [optin] vimd
Parameters:
I>-dump: generate a Java heap dump snapshot. the format is-dump: [live,] format = B, file = <filename>. The live sub-parameter indicates whether to dump only surviving objects.
II>-finalizerinfo: the object displayed in the F-Queue waiting for the Finalizer thread to execute the finalize () method. It is only valid on the Linux/Solaris platform.
III>-heap: displays Java heap details, such as the collector used, parameter value, and generation status, which are valid only on the Linux/Solaris platform.
IV>-histo: displays statistics of objects in the heap, including class, instance quantity, and total capacity.
V>-permstat: Uses ClassLoader as the statistical indicator to display permanent memory replacement. It is only valid on the Linux/Solaris platform.
VI>-F: When the VM process does not respond to the-dump option, you can use this option to forcibly generate a dump snapshot, which is only valid on the Linux/Solaris platform.
Jhat> JVM Heap Dump Browser, used to analyze the heapdump file. It creates an HTTP/HTML server so that you can view the analysis result on the Browser.
Jstack> Stack Trace for Java,Displays the thread snapshot of the VM.
A thread snapshot is a collection of method stacks that are being executed by each thread in the current virtual machine. The main purpose of generating a snapshot is to locate the cause of long thread pauses.
Jstack [option] vmid
Parameters:
I>-F: when normal output requests are not responded, the output thread stack is forced.
II>-l: displays additional information about the lock in addition to the stack.
III>-m: If a local method is called, the C/C ++ stack is displayed.
For example (here is only partial results ):