我有一个Linux盒子,CPU利用率几乎达到最大化.我使用top来追踪有问题的Java进程(12462)和底层线程(12465和12466).我希望运行jstack并在输出中搜索30b1和30b2(前面提到的线程转换为十六进制),这样我就可以弄清楚Java正在做什么.
当我运行没有任何标志的jstack时,它返回以下错误:
12462: 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
但是,当我运行jstack -F时,输出不包含tid或nid信息.这是输出的摘录:
Thread 31374: (state = IN_NATIVE)
- java.net.SocketInputStream.socketRead0(java.io.FileDescriptor, byte[], int, int, int) @bci=0 (Compiled frame; information may be imprecise)
- java.net.SocketInputStream.read(byte[], int, int, int) @bci=79, line=150 (Compiled frame)
- java.net.SocketInputStream.read(byte[], int, int) @bci=11, line=121 (Compiled frame)
- org.apache.coyote.http11.InternalInputBuffer.fill(boolean) @bci=59, line=516 (Compiled frame)
- org.apache.coyote.http11.InternalInputBuffer.fill() @bci=2, line=501 (Compiled frame)
- org.apache.coyote.http11.Http11Processor.setRequestLineReadTimeout() @bci=90, line=173 (Compiled frame)
- org.apache.coyote.http11.AbstractHttp11Processor.process(org.apache.tomcat.util.net.SocketWrapper) @bci=156, line=925 (Compiled frame)
- org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(org.apache.tomcat.util.net.SocketWrapper, org.apache.tomcat.util.net.SocketStatus) @bci=149, line=585 (Compiled frame)
- org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run() @bci=130, line=312 (Compiled frame)
- java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=95, line=1145 (Compiled frame)
- java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=615 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=722 (Interpreted frame)
我跑了jstack -F -l,但命令似乎锁定了.
当我运行jstack -F -m时,我能够找到十进制线程,但输出中没有包含足够的实际Java堆栈,以便我弄清楚它在做什么.这是输出的另一部分:
----------------- 12465 -----------------
0x0000003e54889dd0 _wordcopy_fwd_aligned + 0x140
我错过了什么?我怎样才能让jstack向我展示tid和nid?
解决方法:
当你使用-F时,你无法获得tid和nid.
我相信你正在堆积一些不属于你的pid.在执行jstack之前,尝试切换到拥有pid的用户.请尝试以下命令
sudo -u {user who own the process} jstack -l pid