linux - apache、tomcat 和 mod_jk 和 mysql 的内存泄漏

标签 linux tomcat memory-leaks jvm mod-jk

我在配备 2GB RAM 的 debian-lenny x64 服务器上运行 tomcat 7 和 apache 2.2 & mod_jk 1.2.26。
我的服务器有一个奇怪的问题:每隔几个小时,有时(在负载下)每隔几分钟,我的 tomcat ajp-connector 会因内存泄漏错误而暂停,但似乎这个错误也会影响系统的其他部分(例如其他一些正在运行的应用程序也停止工作)&我必须重新启动服务器才能解决一段时间的问题。
我已经检查了 catalina.out 好几天了,但似乎在暂停 ajp 之前并没有一个独特的错误模式,并显示以下消息:

INFO: Pausing ProtocolHandler ["ajp-bio-8009"]

暂停前有时会有这样的信息:

Exception in thread "ajp-bio-8009-Acceptor-0" java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:597)...

有时是这个:

INFO: Reloading Context with name [] has started
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:597)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5482)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:230)
    at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3847)
    at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:424)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1214)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1400)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1410)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1410)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1389)
    at java.lang.Thread.run(Thread.java:619)
java.sql.SQLException: null,  message from server: "Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug"...

& 有时与程序其他部分相关的输出消息。
我检查了我的应用程序源代码,我不认为它会导致问题,我还使用 jConsole 检查了内存使用情况。 wanderfull 的一点是,当服务器出现故障时,在堆和非堆 jvm 内存空间上都会显示大量空闲内存。正如我之前所说,在服务器崩溃后,许多其他应用程序也会失败,当我想重新启动它们时,它会给出资源暂时不可用的消息(我还检查了我的 limits.conf 文件)。
所以我真的很困惑很多天这个严重的问题,我真的没有更多的想法。那么,有人可以给我任何建议来解决这个复杂且未知的问题吗???
此错误最可能的原因是什么?

最佳答案

您对进程数量的限制是多少?

使用 uname -a 检查它们并检查最大进程数。如果是 1024,则增加它。

此外,检查您正在使用的用户启动它的相同内容(例如,如果您使用 nobody 用户作为您的东西,请运行 su -c "ulimit -a"-s/bin/sh nobody 以查看这个用户实际上认为是限制)。这应该会向您表明一个问题(几天前就有了,完全没有检查这个)。

在这种情况开始发生的那一刻,您还可以使用“ps -eLf | wc -l”为该用户计算所有正在运行的线程和进程(或者甚至更好地使用 rrdtool 或其他工具来监视它),这将给出您支持系统上运行的所有进程和线程的简单计数。此信息以及对所有特定用户的限制应该可以解决您的问题。

关于linux - apache、tomcat 和 mod_jk 和 mysql 的内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13434509/

相关文章:

linux - 将命令行参数传递给 .sh (shell) 文件

c# - 理解有漏洞的应用程序的 Performance Profiler 输出?

ruby - PostgreSQL 查询正在吞噬 VM

linux - 捕获 tomcat 的 pid 以在 Linux 中使用 bash 脚本杀死

linux - BASH:检查系统上安装的内存量作为健全性检查

linux - Apache 无法绑定(bind) :443 address for SSL even though port 443 is unused

tomcat - Kubernetes 单点故障和负载均衡

spring - JSP 表单 : HttpStatus 400: The request sent by the client was syntactically incorrect

java - 在不重新启动 Tomcat 的情况下更改配置/设置

.net - Application.ThreadException : memory leak if not detached?