简体   繁体   English

Tomcat 5.5上突然出现Java堆空间错误

[英]Sudden Java Heap Space errors on Tomcat 5.5

We have a Spring 2.0.8 application in production, running on Tomcat 5.5.x and JRE 1.5.x (yeah, I know, we should upgrade, that's not the point now), with Oracle 11g as our choice of DB. 我们在生产环境中有一个Spring 2.0.8应用程序,它在Tomcat 5.5.x和JRE 1.5.x上运行(是的,我知道,我们应该升级,现在不重要了),并选择Oracle 11g作为数据库。

We have upgraded the application some months ago (I'd say July) and have switched from Oracle 10g to Oracle 11g in the past month or so (also changing the Oracle JDBC driver to match the database version). 我们已经在几个月前(我说是七月)升级了该应用程序,并且在过去一个月左右的时间里已从Oracle 10g切换到Oracle 11g(还更改了Oracle JDBC驱动程序以匹配数据库版本)。

We've been having serious and unexpected problems in production. 我们在生产中遇到了严重而出乎意料的问题。 As of a day ago, there have been heap space OutOfMemory errors several hours apart. 截至一天前,堆空间OutOfMemory错误相隔数小时。 This in turn either slows down response time by about a 100 times, or the users can't connect. 反过来,这可能会使响应时间降低大约100倍,或者用户无法连接。

Our setup is: 我们的设置是:

  • Windows machine to run the server Windows机器上运行服务器
  • Apache 2.2 and Tomcat 5.5 with SSO enabled, total memory: 128MB, max memory: 512MB 启用了SSO的Apache 2.2和Tomcat 5.5,总内存:128MB,最大内存:512MB
  • Spring 2.0.8 Webapp Spring 2.0.8 Webapp
  • Oracle 11g 甲骨文11g

Since noticing this error, this is what we tried: 既然注意到了这个错误,这就是我们尝试的方法:

  • checking out the logs - there doesn't seem to be a pattern. 检查日志-似乎没有模式。 Obviously, logs only tell you when the server is out of memory, so they show the point of not working anymore, instead of the point where the problem started 显然,日志仅告诉您服务器何时内存不足,因此它们显示的是不再工作的点,而不是问题开始的点。
  • restarting server 重新启动服务器
  • reinstalling Tomcat 重新安装Tomcat
  • increasing amount of memory Tomcat can use - this just prolonged the issue, of course Tomcat ate just as much as we gave it Tomcat可以使用越来越多的内存-这只是延长了问题的时间,当然Tomcat吃得和我们给的一样多
  • fresh installation of both the server and Apache+Tomcat 服务器和Apache + Tomcat的全新安装
  • generating heap dumps - nothing spectacular seems out of the ordinary, most memory is used for starting up the application 生成堆转储-似乎没有什么特别之处,大多数内存用于启动应用程序
  • checking the DB - it's fine, quick and responsive, no locks 检查数据库-正常,快速且响应迅速,无锁定

I'm looking out for ideas on what else to do. 我正在寻找其他方法的想法。 We have this same setup in 5 different productions in total, this problematic one being with the smallest number of users and data. 我们总共有5种不同产品的相同设置,而有问题的是用户和数据最少。

Now that you have figured it out, I recommend that you add the following to the list of things to do REAL SOON: 现在您已经弄清楚了,我建议您将以下内容添加到要做REAL SOON的事情列表中:

  • Upgrade your JVM to Java 7. Java 5 has been "end-of-lifed" which means that you won't be getting any more security patches ... unless you are on an Oracle Java support contract. 将JVM升级到Java7。Java5已“报废”,这意味着您将不再获得任何安全补丁……除非您与Oracle Java支持合同签订。

  • If you can't upgrade to Java 7 ... or Java 6, then at least upgrade to the most recent patch release for Java 5 that you can get hold of. 如果您不能升级到Java 7 ...或Java 6,则至少要升级到可以掌握的Java 5最新补丁程序版本。

  • Upgrade to Tomcat 6 or 7, or at least to the most recent Tomcat 5.5. 升级到Tomcat 6或7,或者至少升级到最新的Tomcat 5.5。

  • To head off problems where OutOfMemoryError causes severe slowdowns, make sure that you have the -XX:+UseGCOverheadLimit option on your JVM command line. 要避免OutOfMemoryError导致严重减速的问题,请确保在JVM命令行上具有-XX:+UseGCOverheadLimit选项。

And, if you plan to do any significant development work on that system, consider upgrading it to Spring 3.x. 而且,如果您打算在该系统上进行任何重要的开发工作,请考虑将其升级到Spring3.x。

Ok, we figured this one out. 好的,我们知道了这一点。 It turns out it was a badly written SQL query which was scarcely used. 事实证明,这是一个很少使用的,写得不好的SQL查询。 Analyzing the heapdump helped find the objects that were taking up a lot of memory, and we went from there. 分析堆转储有助于找到占用大量内存的对象,我们从那里开始。

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

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