在不使用 JStack 的情况下从冻结的 Java 应用程序获取线程转储
当我尝试使用 JStack 获取冻结应用程序的线程转储时,其中一个线程给出了以下结果:
Thread 27560: (state = IN_NATIVE)
- org.eclipse.swt.internal.gtk.OS._gtk_adjustment_changed(int) @bci=0 (Compiled frame; information may be imprecise)
Error occurred during stack walking:
java.lang.NullPointerException
at sun.jvm.hotspot.runtime.Frame.addressOfStackSlot(Frame.java:224)
at sun.jvm.hotspot.runtime.x86.X86Frame.senderForCompiledFrame(X86Frame.java:342)
at sun.jvm.hotspot.runtime.x86.X86Frame.sender(X86Frame.java:283)
at sun.jvm.hotspot.runtime.Frame.sender(Frame.java:194)
at sun.jvm.hotspot.runtime.Frame.realSender(Frame.java:199)
at sun.jvm.hotspot.runtime.VFrame.sender(VFrame.java:119)
at sun.jvm.hotspot.runtime.CompiledVFrame.sender(CompiledVFrame.java:178)
at sun.jvm.hotspot.runtime.VFrame.javaSender(VFrame.java:146)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:76)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.tools.jstack.JStack.runJStackTool(JStack.java:118)
at sun.tools.jstack.JStack.main(JStack.java:84)
当然,这是我最感兴趣的:(
Ctrl+Break
也不起作用。还有其他方法可以获取线程转储吗?我使用的是 Linux 和 Sun VM 1.6.0_20。
When I am trying to use JStack to get the thread dump of my frozen application, one of the threads gives me this result:
Thread 27560: (state = IN_NATIVE)
- org.eclipse.swt.internal.gtk.OS._gtk_adjustment_changed(int) @bci=0 (Compiled frame; information may be imprecise)
Error occurred during stack walking:
java.lang.NullPointerException
at sun.jvm.hotspot.runtime.Frame.addressOfStackSlot(Frame.java:224)
at sun.jvm.hotspot.runtime.x86.X86Frame.senderForCompiledFrame(X86Frame.java:342)
at sun.jvm.hotspot.runtime.x86.X86Frame.sender(X86Frame.java:283)
at sun.jvm.hotspot.runtime.Frame.sender(Frame.java:194)
at sun.jvm.hotspot.runtime.Frame.realSender(Frame.java:199)
at sun.jvm.hotspot.runtime.VFrame.sender(VFrame.java:119)
at sun.jvm.hotspot.runtime.CompiledVFrame.sender(CompiledVFrame.java:178)
at sun.jvm.hotspot.runtime.VFrame.javaSender(VFrame.java:146)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:76)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.tools.jstack.JStack.runJStackTool(JStack.java:118)
at sun.tools.jstack.JStack.main(JStack.java:84)
Of course, it is the one I am most interested in :(
Ctrl+Break
doesn't work either. Are there other ways to get a thread dump? I am using Linux and Sun VM 1.6.0_20.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Linux 上,您可能必须在终端中使用
Ctrl+\
来生成线程转储,就像在 UNIX 系统上一样。On Linux you might have to use
Ctrl+\
in the terminal to generate a thread dump as you do on UNIX systems.您可以尝试 VisualVM,这是一个与 Java 6 捆绑在一起的免费工具。我相信它适用于 Linux 以及其他操作系统。
这允许您远程连接到正在运行的 Java 进程、执行线程/堆/应用程序转储以及分析和其他有用的工具。
有关详细信息,请参阅 https://visualvm.dev.java.net/。
You could try VisualVM, a free tool that is bundled with Java 6. I believe it's available for Linux as well as other operating systems.
This allows you to remotely connect to running Java processes, do thread / heap / application dumps, as well as profiling and other useful tools.
See https://visualvm.dev.java.net/ for more information.