JDK Built-in tool JSTACK,JAVAH,JPS,JSTAT,JMAP,JINFO,JCONSOLE,JHAT,JDB,JVISUALVM function and use __js

Source: Internet
Author: User
Tags garbage collection jconsole

Now that I have such a methodical exposition, I will not describe it in detail, address: http://blog.csdn.net/fenglibing/article/details/6411999

Make an outline of how each command works.

1. The JPS command (Java Virtual Machine process Status Tool) is used to view the specific state of all Java processes that have access rights in the Hotspot JVM, including the process ID, the path to start the process, and the startup parameters, and so on, Similar to PS on Unix, except that JPS is used to display Java processes, you can interpret JPS as a subset of PS.  When you use JPS, if you do not specify HostID, it displays only the Java processes in the local environment, and if HostID is specified, it displays the Java process above the specified HostID, although this requires that the JSTATD service be turned on on the remote service. PS: View the Java process directly Linux system PS view can be, the use of a low degree.

2, Javah is used to generate the corresponding C language header file and the corresponding stub file according to the Java local method, PS: Use JNI to use it.

3. Jstack is used to print out Java stack information for a given Java process ID or core file or remote debugging service, and if it is on a 64-bit machine, you need to specify the option "-j-d64". The jstack use of Windows only supports this approach: jstack [-l] PID If a Java program crashes to generate a core file, the Jstack tool can be used to obtain information about the Java stack and native stack of the core file. This makes it easy to know how the Java program crashes and where the problem occurs in the program. In addition, the Jstack tool can also be attached to a running Java program, seeing the Java stack and native stack of Java programs that were running, and jstack is useful if the Java program that is running now renders a hung state. PS: This is the tool of analysis.

4, Jstat used to monitor the hotspot JVM, the use of its heap real-time statistics of the command line, using Jstat we can be the specified JVM to do the following monitoring:

-Loading and unloading of classes

-View capacity and usage of Cenozoic, aged and permanent generations

-View garbage collection for the generation, generation and persistence generations, including the number of garbage collections and the time taken by garbage collections

-View capacity and distribution in the new generation of Eden and Survior areas

The Jstat tool is particularly powerful and has many options, providing a variety of monitoring dimensions that allow us to understand the current usage of the JVM heap from different dimensions. Detailed view of the use of the various parts of the heap, when used must add the Java process number to be counted, optional different dimension parameters and optional statistical frequency parameters.

It is mainly used to display GC and PermGen related information, if you do not understand the GC, read this article first: http://blog.csdn.net/fenglibing/archive/2011/04/13/6321453.aspx, Otherwise, even if you would use the Jstat command, you would not be able to read its output. PS: This is an artifact.


5, print out a Java process (using PID) in memory, all the ' objects ' situation (such as: produce those objects, and their number).

You can output tools for all in-memory objects, and you can even heap the VM into text in binary form. Use the method Jmap-histo pid. If you use the shell Jmap-histo Pid>a.log to save it to text, after a while, you can compare which objects the GC reclaims by using the text Contrast tool. Jmap-dump:format=b,file=outfile 3024 can output the memory heap of the 3024 process to outfile file, and then cooperate with Mat (The Memory Analyzer tool (Memory analysis Tool), using see: http ://blog.csdn.net/fenglibing/archive/2011/04/02/6298326.aspx) or used with Jhat (Java Heap analysis Tool), The ability to visually display the current memory in the form of an image is problematic.

The use of 64-bit machines requires the following: Jmap-j-d64-heap pid PS: Memory usage


6, Jinfo can output and modify the Run-time Java process opts. It is simple to use to output Java system parameters and command line parameters. Usage is jinfo-opt pid such as: View 2788 maxperm size can be used Jinfo-flag maxpermsize 2788.


7. Jconsole: A Java GUI monitoring tool that displays a variety of data in a graphical format. Remote connections can be used to monitor the server VM remotely. Java-written GUI programs, used to monitor VMS and monitor remote VMS, are very easy to use and very powerful. Jconsole in the command line, the selection process is OK. It is important to note that before running Jconsole, you must set the environment variable DISPLAY first, otherwise you will report errors, Linux settings under the environment variables are as follows: Export display=:0.0 PS: Simple and practical


8, JVISUALVM with Jconsole is a graphical interface, you can view the local and remote Java GUI monitoring tools, JVISUALVM and jconsole use the same way, directly in the command line into the JVISUALVM can start, But compared to JVISUALVM, the interface is more beautiful, the data more real-time Ps:jconsole enhanced version


9, Jhat for the Java Heap Off-line analysis tool, he can be exported to different virtual machines heap information file analysis. PS: Not as powerful as mat.


10, JDB remote debugging. Ps:ide remote debugging can be, with this is not beautiful, of course, the environment is very poor or can be used.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.