Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

JVM monitoring command

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

JDK itself provides many convenient JVM performance tuning monitoring tools, in addition to integrated VisualVM and jConsole, there are gadgets such as jps,jmap,jstat,jstack,jhat.

1. Jps (Java Virtual Machine Process Status Tool)

Jps-m-l lists the status information of processes running in JVM (here you can get the pid of a process for use by subsequent commands)

2. Jstat

Jstat-gcutil pid 10s 3 performs real-time command line statistics on heap memory usage, gc information, etc.

3. Jstack

View thread stack information within a Java process.

Jstack can navigate to the thread stack, and we can navigate to specific code based on stack information, so it is used a lot in JVM performance tuning.

For more information on how to use it, see 6. Hot spot CPU

4. Jmap

Generate heap memory snapshot

Jmap-heap pid can view the process heap memory information and understand it.

Jmap-dump:format=b,file=xxx.hprof pid dump the process memory usage into a file. The Dump file is the memory image of the process

Jmap-dump:live,format=b,file=xxx.hprof pid statistics of surviving object information

Files from dump can be viewed with MAT, VisualVM and other tools, or with jhat.

5. Jhat

View the files from dump

Jhat-port 9998 xxx.hprof

Then you can enter the host address: 9998 in the browser to view it, such as: http://localhost:9998

Not recommended, because some files are very large, it will be very slow to open, it seems difficult to promote the use of MAT analysis

6. Hot spot cpu

The occupancy rate of cpu is relatively high.

Positioning steps:

Jps-m-l lists running processes-is it better to use the top command here? Top can see who occupies the highest cpu.

Top-H-p pid finds the thread in the process that consumes the most cpu

Printf "% x\ n" tid thread id converted to hexadecimal

Jstack pid | convert grep to hexadecimal tid-A 50

Note 1: in the information displayed, focus on the code written by yourself, and take screenshots for the developer.

Note 2: it is possible that jstack cannot capture the required information at one time, so it needs to be executed multiple times, because it captures the state of that moment.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report