1

I have s.t. like a infinite loop some where in the code. That place is somehow not called often. So after a couple of hours one of the CPU's on the Linux machine start's running at 100% then after a while another one etc. Restarting the server solves the problem for a while.

How can i find the place where this happens?

I thought about setting the RequestTimeout very small. (5 min) Would I get a proper error message in the log that tells me what's wrong.

top with command "H"

16639 java 20 0 9836m 2.6g 17m R 100 16.5 39:55.33 java 18059 java 20 0 2745m 2.3g 17m S 2 14.5 0:00.92 java 16591 java 20 0 9836m 2.6g 17m S 1 16.5 0:15.97 java 5307 java 20 0 8945m 4.6g 3864 S 1 29.1 746:47.67 java

and then: jstack -J-d64 16639

But I get: 16639: Unable to open socket file: target process not responding or HotSpot VM not loaded The -F option can be used when the target process is not responding

Must I start s.t. on the machine before?

Nice article about how to search for the hotspot:

http://code.nomad-labs.com/2010/11/18/identifying-which-java-thread-is-consuming-most-cpu/

4

1 回答 1

2

如果您在机器中具有特权,则可以执行jstack.

jstack在应用程序上执行线程转储。从那里您可以检查哪个线程处于无限循环中。

Jstackjdk.

另一种方法是检查top命令 (*nix) 并启用线程视图。从那里您可以检查哪个线程正在消耗 CPU。然后jstack你可以看到一个nid线程的十六进制值。

您可以使用jps获取java pid。

于 2013-04-30T15:49:57.027 回答