问题
I have a java application, that seems to be stuck. I tried kill -3 but the output is empty (it is redirected to file but nothing is there).
what way can I see what it is doing?
EDIT:
I tried jstack but it crashed:
Linux # /usr/pkgs/java/1.6.0.25/bin/jstack -F -l 12666
Attaching to process ID 12666, please wait...
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0xaf121777, pid=5423, tid=2937191328
JRE version: 6.0_25-b06
Java VM: Java HotSpot(TM) Server VM (20.0-b11 mixed mode linux-x86 )
Problematic frame:
C [libsaproc.so+0x1777] void+0x1777
...
EDIT2:
this is jvisualvm crash:
Linux # /usr/pkgs/java/1.6.0.25/bin/jvisualvm
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0xf36d0777, pid=18217, tid=4090493856
JRE version: 6.0_25-b06
Java VM: Java HotSpot(TM) Client VM (20.0-b11 mixed mode, sharing linux-x86 )
Problematic frame:
C [libsaproc.so+0x1777] void+0x1777
An error report file with more information is saved as:
/tmp/root/feeder_wa/coho_idc/logs/hs_err_pid18217.log
If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.
/usr/pkgs/java/1.6.0.25/bin/../lib/visualvm//platform/lib/nbexec: line 539: 18217 Aborted "/usr/pkgs/java/1.6.0.25/bin/java" -Djdk.home="/usr/pkgs/java/1.6.0.25" -classpath "/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/boot.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/org-openide-modules.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/org-openide-util-lookup.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/org-openide-util.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/locale/boot_ja.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/locale/boot_zh_CN.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/locale/org-openide-modules_ja.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/locale/org-openide-modules_zh_CN.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/locale/org-openide-util-lookup_ja.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/locale/org-openide-util-lookup_zh_CN.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/locale/org-openide-util_ja.jar:/usr/pkgs/java/1.6.0.25/lib/visualvm/platform/lib/locale/org-openide-util_zh_CN.jar:/usr/pkgs/java/1.6.0.25/lib/dt.jar:/usr/pkgs/java/1.6.0.25/lib/tools.jar" -Dnetbeans.dirs="/usr/pkgs/java/1.6.0.25/bin/../lib/visualvm//visualvm:/usr/pkgs/java/1.6.0.25/bin/../lib/visualvm//profiler:" -Dnetbeans.home="/usr/pkgs/java/1.6.0.25/lib/visualvm/platform" '-client' '-Xms24m' '-Xmx256m' '-Dsun.jvmstat.perdata.syncWaitMs=10000' '-Dsun.java2d.noddraw=true' '-Dsun.java2d.d3d=false' -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="/root/.visualvm/6u23/var/log/heapdump.hprof" org.netbeans.Main --userdir "/root/.visualvm/6u23" "--branding" "visualvm" 0<&0
回答1:
Try VisuamVM, you can find it in every JDK after version 6 at jdkInstallDir/bin/visualvm
.
回答2:
I think you are out of luck. Sometimes an application goes into a dead state that cannot be thread dumped by anything, kill, jstack or jvisualvm.
If this is happening regularly, then setup a schedule thread dump and possibly jmap -histo:live. You need to gather thread and memory dumps before the application becomes unresponsive. I prefer dumps to text files because you can leave a script running overnight running every half hour, doesn't require a display and can be easily processed by things like grep. Jvisualvm is great for finding the root cause of memory leaks, but first determine you have one, as it can stress your application out and cause a crash.
来源:https://stackoverflow.com/questions/6490756/kill-3-return-empty