http://www.tecmint.com/12-top-command-examples-in-linux/
[原文地址:http://os.51cto.com/art/201108/286625.htm]
找到最耗CPU的java线程
ps命令
命令:
ps -mp pid -o THREAD,tid,time 或者 ps -Lfp pid
结果展示:
这个命令的作用,主要是可以获取到对应一个进程下的线程的一些信息。 比如你想分析一下一个java进程的一些运行瓶颈点,可以通过该命令找到所有当前Thread的占用CPU的时间,也就是这里的最后一列。
比如这里找到了一个TID : 30834 ,所占用的TIME时间最高。
通过 printf "%x\n" 30834 首先转化成16进制, 继续通过jstack命令dump出当前的jvm进程的堆栈信息。 通过Grep命令即可以查到对应16进制的线程id信息,很快就可以找到对应最耗CPU的代码快在哪。
简单的解释下,jstack下这一串线程信息内容:
800 nid=0x7d9b waiting on condition [0x0000000046f66000] "DboServiceProcessor-4-thread-295" daemon prio=10 tid=0x00002aab047a9800 nid=0x7d9b waiting on condition [0x0000000046f66000]
nid : 对应的linux操作系统下的tid,就是前面转化的16进制数字
tid: 这个应该是jvm的jmm内存规范中的唯一地址定位,如果你详细分析jvm的一些内存数据时用得上,我自己还没到那种程度,所以先放下
top命令
命令:
top -Hp pid
结果显示:
和前面的效果一下,你可以实时的跟踪并获取指定进程中最耗cpu的线程。 再用前面的方法提取到对应的线程堆栈信息。
[自己的阅读说明]
pid process Id
TID thread id
gid user 的group id
相关推荐
DB2 System Command Examples
The Complete Guide to "useradd" Command in Linux - 15 Practical Examples.pdf
经典图书,有大量实例,方便学习; Bayesian Networks With Examples in R
Rx.NET in Action With examples in C# Rx.NET in Action With examples in C#
Java Examples in a Nutshell(3rd) 英文epub 第3版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Examples in Linux C and C++ for the book Programming Embedded Systems in C and C++ written Michael Barr
Microservices Patterns teaches enterprise developers and architects how to build applications with the microservice architecture. Rather than simply advocating for the use the microservice ...
r语言实现贝叶斯网络,里面包含各种案例,对贝叶斯模型进行深入讲解,包括结构学习、参数学习、推理三部分
linux设备驱动3(ldd3) 源码 examples 支持 linux-2.6.32.2,源码是从网上找的,自己修改后可以在linux-2.6.32.2内核环境下编译通过.注意把Makefile中的KERNELDIR ?= /home/code/buildroot/mini2440/linux-2.6.32.2改为...
国外的一本概率论与数理统计中的反例,这些反例帮助澄清一些概率论与数理统计中的误会,从而更加地有助于概率论与数理统计的理解
principles packed with real-world applications and examples. Authored by professionals experienced in information systems security, they deliver comprehensive information on all aspects of information...
作者 Gary L. Wise / Eric B. Hall. 1993
Advanced Methods in Computer Graphics - With Examples in OpenGL
Manning Microservices in .Net Core with examples in Nancy
Java Examples In A Nutshell
史诗级别的Java基础教程----巨人的进阶
The Art of Unit Testing builds on top of what's already been written about this important topic. It guides you step by step from simple tests to tests that are maintainable, readable, and trustworthy....
Design Pattern Examples in C#
Linux in Action guides you through 12 real-world projects, including automating a backup-and-restore system, setting up a private Dropbox-style file cloud, and building your own MediaWiki server....