简体   繁体   English

为什么 Tomcat 5.5(带 Java 1.4,在 Windows XP 32 位上运行)突然挂起?

[英]Why does Tomcat 5.5 (with Java 1.4, running on Windows XP 32-bit) suddenly hang?

I've been running Tomcat 5.5 with Java 1.4 for a while now with a huge webapp.我已经运行 Tomcat 5.5 和 Java 1.4 有一段时间了,现在有一个巨大的 web 应用程序。 Most of the time it runs fine, but sometimes it will just hang, with no exception generated, and no apparant way of getting it to run again other than re-starting Tomcat.大多数时候它运行良好,但有时它会挂起,不会产生异常,除了重新启动 Tomcat 之外,没有明显的方法让它再次运行。 The tomcat instance is allowed a gigabyte of memory on the heap, but rarely exceeds 300 MB. tomcat 实例在堆上允许有千兆字节的 memory,但很少超过 300 MB。 Has anyone else run into this issue, and is there a solution for it?有没有其他人遇到过这个问题,是否有解决方案?

For clarification: I determined how much memory it is using via Task Manager and via Eclipse (I've also tried running it outside of Eclipse, but get the same problem eventually, though it takes a little longer).澄清一下:我通过任务管理器和 Eclipse 确定了它使用了多少 memory (我也尝试在 Eclipse 之外运行它,但最终得到了同样的问题,但它需要更长的时间,但是) With Eclipse, I look at the memory allocated via its little (optional) memory pane and the amount allocated to javaw.exe via the task manager.使用 Eclipse,我查看通过其小(可选)memory 窗格分配的 memory 和通过任务管理器分配给 javaw.exe 的数量。 I use the sysdeo?我用的是sysdeo? tomcat plugin for Eclipse. Eclipse 的 tomcat 插件。

For any jvm process, force a thread dump.对于任何 jvm 进程,强制执行线程转储。 In windows, this can be done with CTRL-BREAK, I believe, in the console window.在 windows 中,我相信在控制台 window 中,可以使用 CTRL-BREAK 来完成。

In *nix, it is almost always "kill -3 jvm-pid".在 *nix 中,它几乎总是“kill -3 jvm-pid”。

This may show if you have threads waiting on db connection pool/thread pool, etc.这可能会显示您是否有线程在数据库连接池/线程池等上等待。

Another thing to check out is how many connections you have currently to the JVM -- either use NETSTAT or SysInternals utility such as tcpconn/tcpview (google it).要检查的另一件事是您当前与 JVM 有多少连接 - 使用 NETSTAT 或 SysInternals 实用程序,例如 tcpconn/tcpview (google it)。

Also, try to run with the verbose:gc JVM flag.此外,尝试使用 verbose:gc JVM 标志运行。 For Sun's JVM, run like "java -verbose:gc".对于 Sun 的 JVM,像“java -verbose:gc”一样运行。 This will show your garbage collections.这将显示您的垃圾 collections。 If it is collecting a lot (FULL COLLECTIONS, expecially) then you probably have a memory leak.如果它收集了很多(特别是完整的 COLLECTIONS),那么您可能有 memory 泄漏。 The full collections are costly, especially on large heaps like that.完整的 collections 成本很高,尤其是在这样的大堆上。

How are you determining that only 300mb are being used?您如何确定仅使用了 300mb?

It sounds like you're hitting a deadlock.听起来你正在陷入僵局。

If you can reproduce it in a dev environment then try attaching a debugger once it's happened.如果您可以在开发环境中重现它,那么在它发生后尝试附加调试器。 Take a look at your threads and see if you have any deadlocks.看看你的线程,看看你是否有任何死锁。

If you can't get a debugger to attach you should be able to generate a thread dump, as Dustin pointed out.正如 Dustin 指出的那样,如果您无法附加调试器,您应该能够生成线程转储。

Try increasing the logging sensitivity for the Tomcat application server.尝试增加 Tomcat 应用服务器的日志记录敏感度。 http://tomcat.apache.org/tomcat-5.5-doc/logging.html http://tomcat.apache.org/tomcat-5.5-doc/logging.html

You can increase the sensitivity to FINEST or ALL for most of them for a few days and see if that helps you catch anything.您可以在几天内提高大多数人对 FINEST 或 ALL 的敏感度,看看这是否有助于您捕捉到任何东西。

I agree with creating multiple thread dumps and viewing them though this: Thread Dump Analyzer我同意创建多个线程转储并通过以下方式查看它们: Thread Dump Analyzer

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

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