Built-in commands for common stack tracing in JVM

Source: Internet
Author: User

Built-in commands for common stack tracing in JVM

Java programs may encounter program exceptions. In this case, you can use jstack and jmap under JDK to track and observe the memory stack information in JVM for analysis, however, it should be noted that it is generally unavailable in Windows or open-source versions. If you need to install corresponding development and debugging tools, the following is a simple description:

Generally, jstack is followed by the pid of the Java program running or the corresponding Java code file, such as jstack $ pid, you can export the relevant stack information to a file for further observation, such as jstack $ pid> file. dump

Jmap functions are similar to those of jstack. However, jmap is more powerful than jstack. It is also followed by the pid program running in Java, but it also has some Parameter options:

These parameters are not included by default, and only some simple information can be printed.
-Heap: used to print the summary of the Java stack
-Histo [: live] is used to print real-time stack information and is often used for real-time stack tracking.
-Clstats is used to print the information of class loading in Java.
-Finalizerinfo: used to print information about objects waiting for confirmation.
-Dump: <dump-options> dump related stack information to binary files for development and debugging tools, for example, jmap-dump: format = B, file = Java_jmp.bin $ pid
-F this option is used with the-dump option, indicating that the real-time stack information is not printed in the binary file generated by the dump, but other information is printed.
-J <flag> transmits the flag to the Java program, that is, when the breakpoint is executed

In short, when an exception occurs in a Java program, the use of the relevant stack tracking built-in commands can be a good way to troubleshoot the problem.

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.