Java 似乎挂起

发布于 2024-07-14 21:32:49 字数 461 浏览 13 评论 0原文

我在自定义应用程序中使用 Java 服务包装器已经有一段时间了,并且运行良好。 自从最近几天将我们的应用程序更新到新版本以来,JVM 开始挂起,然后包装器在日志中打印以下内容: JVM 显示挂起:等待来自 JVM 的信号超时。

然后它会自动终止 JVM 并再次启动应用程序。 这种情况发生在运行大约 10 小时后,这只会增加调试的难度。

当然,我将仔细检查我们所做的更改,但没有进行任何我怀疑会导致此类问题的重大更改。

我可以在哪里查看以尝试找出正在发生的情况? 来自应用程序的调试消息没有表明任何有趣的事情。 如果 JVM 只是崩溃,它通常会创建一个转储,这可以帮助调试它,但它挂起,所以它不会创建转储。 如果我让它不自动重新启动服务,我可以做些什么来在重新启动之前从 JVM 中获取一些有用的信息?

在我看来,JVM 不应该因典型的编程错误而挂起。 您之前遇到过什么情况会导致 JVM 挂起?

I've been using the Java Service wrapper in a custom application for quite a while and it's been working fine. Since updating our application to a new version in the last few days the JVM started hanging and then wrapper prints this in the log:
JVM appears hung: Timed out waiting for signal from JVM.

It then automatically terminates the JVM and starts the app again. This happens after about 10 hours of running, which just makes it harder to debug.

Of course I am going to look through the changes that we've made, but no major changes were made that I would suspect is causing this type of problem.

Where can I look to try and figure out what is happening? Debug messages from the application don't indicate anything interesting. If the JVM just crashes it will usually create a dump, which can help in debugging it, but it's hanging, so it's not creating a dump. If I make it not restart the service automatically is there anything I can do to get some useful information out of the JVM before restarting it?

It seems to me that the JVM shouldn't hang from typical programming errors. What have you run into before that can cause the JVM to hang?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

静若繁花 2024-07-21 21:32:49

阅读wrapper.ping.timeout 属性。 包装器软件经常与您的 JVM 进行通信,以确保它处于活动状态。 如果该通信由于某种原因失败,包装器会认为该进程挂起并尝试重新启动它。

根据应用程序的架构方式,当包装器尝试“ping”它时,您的 JVM 可能正忙于处理其他内容。

Read up on the wrapper.ping.timeout property. The wrapper software communicates with your JVM every so often to make sure that it is alive. If that communication fails for whatever reason, the wrapper deems the process hung and attempts to restart it.

Depending on how your application is architected, your JVM might be busy processing something else when the wrapper tries to "ping" it.

注定孤独终老 2024-07-21 21:32:49

看看是否可以使用 Visual VM 来看看发生了什么。 让 Visual VM 全程监控应用程序,当它停止工作时,您也许可以确定出了什么问题。

如果VM挂起,您可以获取线程的状态...我认为Visual VM将使它比通常的ctrl-break(或任何组合键)更容易给定您的设置。

(根据评论编辑)

尝试过这个。 上次挂了
线程数和数量
使用的内存非常低,所以
这些都不会导致
问题。 不幸的是挂起后
并且包装器终止它,你不能
获取线程转储。

有什么方法可以在没有包装器的情况下运行它来调试它吗? 另外,如果您使用 NetBeans 分析器,它可能会给您一个在它停止时处理它的机会(我将在今天晚些时候检查,看看是否可以找出是否会有不同的行为)。

See if you can use the Visual VM to see what is going on. Have the Visual VM monitor the app for the whole time and when it stops working perhaps you can determine what is wrong.

If the VM hangs you can get the state of the threads... I think the Visual VM will make it a bit easier given your setup than the usual ctrl-break (or whatver the key combo is).

(Edit based on comment)

Tried this. Last time it hung the
number of threads and the amount of
memory in use were quite low, so
neither of those are causing the
problem. Unfortunately after it hangs
and wrapper terminates it you can't
get a thread dump.

Is there any way you can run it without the wrapper to debug it? Also if you use the NetBeans profiler it might give you a chance to deal with it when it stops (I'll check later today and see if I can find out if that would behave differently).

放血 2024-07-21 21:32:49

我在类路径 (JBPM) 上有几个不同版本的库。 使用包装器,您可以使用通配符来包含 jar。 但要小心这一点,因为您可能会不小心包含超出应有的内容。

这是一篇 IBM 文章,提供有关 Java 中的调试挂起。 它基本上说有两种情况可能导致挂起:

  1. 无限循环,
  2. 死锁。

从那时起,我不得不调试其他悬而未决的问题。 在 Linux 上,您可以向 JVM 发送 QUIT 信号,使其将线程转储到控制台。 这确实有助于找出问题所在。 使用以下命令来执行此操作:kill -QUIT

Edit 6/13/2017

这些天我使用 JDK 中包含的 jmap 来转储程序的整个内存。 然后我使用 Eclipse Memory Analyzer 查看程序崩溃时的确切状态。 您可以查看活动线程列表,然后检查每个堆栈帧中的变量。

/usr/java/latest/bin/jmap -dump:file=/tmp/app-crash.hprof <PID>

其中PID是java进程的进程ID。

I had a couple different versions of a library on the classpath (JBPM). With wrapper you can use wildcards to include jars. Be careful with this though as you may accidentally include more than you should.

Here is an IBM article that gives information on debugging hangs in Java. It basically says that there are two things that can cause hangs:

  1. An infinite loop,
  2. A deadlock.

Since then I've had to debug other hanging issues. On linux you can send the JVM the QUIT signal to make it do a thread dump to the console. This really helps figuring out where the issue is. Use this command to do that: kill -QUIT

Edit 6/13/2017

These days I use jmap included in the JDK to dump the entire memory of the program. Then I use Eclipse Memory Analyzer to see the exact state of the program when it crashed. You can look at the list of threads that are active and then inspect the variables in each stack frame.

/usr/java/latest/bin/jmap -dump:file=/tmp/app-crash.hprof <PID>

Where PID is the process ID of the java process.

云裳 2024-07-21 21:32:49

你处于什么环境? 操作系统、JVM版本、硬件架构?

这听起来确实像一个错误,而且考虑到它需要花费很多小时,它听起来像是某种资源耗尽错误。

What environment are you in? OS, JVM version, hardware architecture?

That does sound like a bug, and given that it takes many hours, it sounds like a resource-exhaustion bug of some sort.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文