简体   繁体   English

如何调试偶尔挂起的JVM

[英]How to debug JVM hanging on exit occasionally

I have a server that occasionally hangs when it exits. 我有一台服务器,它会在退出时偶尔挂起。 The hang only occures about 1/10 or less of the time and so far we can't figure out a way to reliably recreate the issue. 挂起仅发生在大约1/10或更少的时间,到目前为止我们无法找到可靠地重新创建问题的方法。 I've walked through my code and thought that I am closing all resources and killing my threads, but obviously some of the time I don't close right. 我已经浏览了我的代码,并认为我正在关闭所有资源并杀死我的线程,但显然有些时候我没有关闭。

Can anyone suggest debugging tips to help me test this when I can't reliably recreate it? 任何人都可以建议调试技巧,以帮助我测试这个,当我无法可靠地重新创建它? I've tried running JVisualVM once it goes down, but it doesn't help much other then showing me the sigterm threads are running still and everything is at 0% CPU, which I assume means a deadlock somewhere. 我已经尝试过运行JVisualVM,但它没有多大帮助,然后向我显示sigterm线程仍在运行且一切都在0%CPU,我认为这意味着某处死锁。

You could try using JConsole to monitor your server. 您可以尝试使用JConsole来监视您的服务器。 You can visually monitor the memory, CPU usages and no of threads etc. It also can detect deadlocks if there are. 您可以直观地监视内存,CPU使用情况和没有线程等。如果有,也可以检测到死锁。

When the process hangs you can send SIGQUIT (kill -3) to the process and it will generate a thread dump. 当进程挂起时,您可以向进程发送SIGQUIT(kill -3),它​​将生成一个线程转储。 The output goes to stderr so make sure that is being captured. 输出转到stderr,因此请确保正在捕获。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM