开发者

How to see what my Java process is doing right now?

I have an app server process that's constantly at 100% CPU. By constantly I mean hours, or even days.

I know how to generate a heap/thread开发者_运维知识库 dump, but I'm looking for more dynamic information. I would like to know what is using so much CPU in there. There are tens (or probably 100+) threads. I know what those threads are, but I need to know which of them are using my CPU so much.

How can I obtain this information?


Use a profiler. There is one included in VisualVM which comes with the Oracle JDK.

An advanced commercial one (trial licenses available) is YourKit.


By creating a thread dump. You can use the jstack to connect to a running java process to get the thread dump. If you take two or more thread dumps over a period of time you can by analyzing them figure out which ones are actively using CPU. Typically the threads in the RUNNING state are the ones you need to focus on.


I personally use YourKit for this.

VisualVM also has some profiling capabilities, but I haven't used them.


in linux try kill -3 processid it will generate thread dump. You can analyze this to see what is happening in the java process.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜