Tomcat修复内存泄漏? [英] Tomcat Fix Memory Leak?

查看:147
本文介绍了Tomcat修复内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用6.0.20我在服务器上运行了许多网络应用程序,随着时间的推移,大约3天,服务器需要重新启动,否则服务器崩溃并变得无响应。

I am using 6.0.20 I have a number of web apps running on the server, over time, approximately 3 days and the server needs restarting otherwise the server crashes and becomes unresponsive.

我对JVM有以下设置:

I have the following settings for the JVM:

-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=c:\tomcat\Websites\private\mydomain\apache-tomcat-6.0.20\logs

这为我提供了一个hprof文件,我使用Java VisualVM加载了该文件,该文件标识了以下内容:

This provides me with a hprof file which I have loaded using Java VisualVM which identifies the following:

byte[] 37,206   Instances | Size 86,508,978
int[] 540,909   Instances | Size 55,130,332
char[] 357,847  Instances | Size 41,690,928

列表继续,但我如何确定导致这些问题的原因?

The list goes on, but how do I determine what is causing these issues?

我正在使用New Relic监视JVM,似乎只出现了一个错误,但它是一个重复发生的错误,org.apache.catalina.connector。 ClientAbortException。是否有可能在用户会话中止时,创建的任何数据库连接或变量都没有被关闭并因此被隔离?

I am using New Relic to monitor the JVM and only one error seems to appear but it's a reoccurring one, org.apache.catalina.connector. ClientAbortException. Is it possible that when a user session is aborted, any database connections or variables created are not being closed and are therefore left orphaned?

有一个功能使用得相当在每个Web应用程序中都很重要,不确定这是否与泄漏有关:

There is a function which is used quite heavily throughout each web app, not sure if this has any bearing on the leak:

public static String replaceCharacters(String s)
{
    s = s.replaceAll("  ", " ");
    s = s.replaceAll(" ", "_");
    s = s.replaceAll("\351", "e");
    s = s.replaceAll("/", "");
    s = s.replaceAll("--", "-");
    s = s.replaceAll("&", "and");
    s = s.replaceAll("&", "and");
    s = s.replaceAll("__", "_");
    s = s.replaceAll("\\(", "");
    s = s.replaceAll("\\)", "");
    s = s.replaceAll(",", "");
    s = s.replaceAll(":", "");
    s = s.replaceAll("\374", "u");
    s = s.replaceAll("-", "_");
    s = s.replaceAll("\\+", "and");
    s = s.replaceAll("\"", "");
    s = s.replaceAll("\\[", "");
    s = s.replaceAll("\\]", "");
    s = s.replaceAll("\\*", "");
    return s;
}

当用户连接中止时,例如用户浏览器关闭或用户已离开网站所有变量,连接等等......被清除/释放,但GC不应该处理吗?

Is it possible that when a user connection is aborted, such as a user browser closed or the users has left the site that all variables, connections, etc... are purged/released, but isn't GC supposed to handled that?

以下是我的JVM设置:

Below are my JVM settings:

-Dcatalina.base=c:\tomcat\Websites\private\mydomain\apache-tomcat-6.0.20
-Dcatalina.home=c:\tomcat\Websites\private\mydomain\apache-tomcat-6.0.20
-Djava.endorsed.dirs=c:\tomcat\Websites\private\mydomain\apache-tomcat-6.0.20\endorsed
-Djava.io.tmpdir=c:\tomcat\Websites\private\mydomain\apache-tomcat-6.0.20\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=c:\tomcat\Websites\private\mydomain\apache-tomcat-6.0.20\conf\logging.properties
-Dfile.encoding=UTF-8
-Dsun.jnu.encoding=UTF-8
-javaagent:c:\tomcat\Websites\private\mydomain\apache-tomcat-6.0.20\newrelic\newrelic.jar
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=c:\tomcat\Websites\private\mydomain\apache-tomcat-6.0.20\logs
-Dcom.sun.management.jmxremote.port=8086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false vfprintf
-Xms1024m
-Xmx1536m

我错过了什么吗?服务器有3GB内存。

Am I missing anything? The server has 3GB ram.

任何帮助都将不胜感激: - )

Any help would be much appreciated :-)

推荐答案

我将所有项目迁移到Tomcat 7.0.42并且我的错误已经消失,我们的网站更稳定,速度更快,我们使用更少的内存和cpu使用情况要好得多。

I migrated all projects to Tomcat 7.0.42 and my errors have disappeared, our websites are far more stable and slightly faster, we are using less memory and cpu usage is far better.

这篇关于Tomcat修复内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆