Home  >  Article  >  Java  >  How to check jvm and thread usage

How to check jvm and thread usage

王林
王林Original
2020-10-21 15:33:554782browse

How to check jvm and thread usage: execute the [jmap -heap PID] command to check the jvm usage; execute the [jstack pid] command to check the thread usage.

How to check jvm and thread usage

View jvm usage

(Video tutorial recommendation: java course)

jmap -heap PID

View Thread usage

jstack pid

jstack is a stack tracing tool that comes with the Java virtual machine and is used to generate a thread snapshot of the current moment of the Java virtual machine.

Thread snapshots are a collection of method stacks being executed by each thread in the current Java virtual machine. The main purpose of generating thread snapshots is to locate the reasons for long pauses in threads, such as inter-thread deadlocks, infinite loops, etc. Long waits caused by requesting external resources, etc.

When a thread pauses, you can check the call stack of each thread through jstack to know what the unresponsive thread is doing in the background or what resources it is waiting for. If the Java program crashes and generates a core file, the jstack tool can be used to obtain the Java stack and native stack information of the core file, so that you can easily know how the Java program crashed and where the problem occurred in the program.

In addition, the jstack tool can also be attached to the running java program to see the java stack and native stack information of the java program running at that time. If the java program currently running is in a hung state, jstack is Very useful.

Related recommendations:Getting started with java

The above is the detailed content of How to check jvm and thread usage. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn