在不使用JStack的情况下从冻结的Java应用程序获取线程转储

时间:2010-08-31 14:34:02

标签: java debugging thread-dump

当我尝试使用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。

2 个答案:

答案 0 :(得分:3)

在Linux上,您可能必须在终端中使用Ctrl+\来生成线程转储,就像在UNIX系统上一样。

答案 1 :(得分:2)

您可以尝试VisualVM,这是一个与Java 6捆绑在一起的免费工具。我相信它可用于Linux以及其他操作系统。

这允许您远程连接到正在运行的Java进程,执行线程/堆/应用程序转储,以及分析和其他有用的工具。

有关详细信息,请参阅https://visualvm.dev.java.net/