简体   繁体   English

为什么配置c3p0后出现内存泄漏异常?

[英]Why I am getting memory leak exception after c3p0 configuration?

I am using java , GWT, and hibernate with mysql. 我正在使用java,GWT和mysql休眠。 To avoide too many connection exception I am configuring the c3p0 in my application, but after configuration when I deploy my application to tomcat and run application so after 5 to 10 request application gets crashed and in tomcat logs I am getting following exception repeatedly: 为了避免过多的连接异常,我正在应用程序中配置c3p0,但是在配置后,当我将应用程序部署到tomcat并运行应用程序时,因此在5到10个请求应用程序崩溃之后,并且在tomcat日志中,我反复收到以下异常:

org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/war] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1d2aa39]) and a value of type [com.google.inject.servlet.ServletDefinition$2] (value [com.google.inject.servlet.ServletDefinition$2@ef3675]) but failed to remove it when the web application was stopped.Threads are going to be renewed over time to try and avoid a probable memory leak.

My c3p0 configuration is as follows: 我的c3p0配置如下:

<property name="connection.provider_class"> org.hibernate.connection.C3P0ConnectionProvider</property>
   <property name="hibernate.connection.autoReconnect">true</property>
   <property name="hibernate.c3p0.acquire_increment">3</property>
   <property name="hibernate.c3p0.idle_test_period">5</property>
   <property name="hibernate.c3p0.max_size">50</property>
   <property name="hibernate.c3p0.max_statements">0</property>
   <property name="hibernate.c3p0.min_size">0</property>
   <property name="hibernate.c3p0.timeout">5</property>
   <property name="hibernate.c3p0.idleConnectionTestPeriod">5</property>

help me if anyone knows the solution... thanks in advance.. 如果有人知道解决方案,请帮助我。

This is not the cause of your crash, but its effect —your app has crashed for a yet unknown reason and left a mess behind it. 这不是导致崩溃的原因 ,而是它的后果-您的应用因未知原因而崩溃,并造成了混乱。 The error pertains to that mess. 该错误与该混乱有关。

This is a class-loader related memory leak that occurs when you redeploy your application. 当您重新部署应用程序时,这是与类加载器有关的内存泄漏。

For more information on this type of memory leak, see this question . 有关此类内存泄漏的更多信息,请参阅此问题

The problem in your case is a bug in the Guava dependency of Google Guice. 您遇到的问题是Google Guice 的Guava依赖项存在错误

您可以在此链接中查找造成这种情况的原因: http : //people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf

This is not the cause of your exception ,but the outcome of the exception. 这不是您异常的原因,而是异常的结果。 The most probable reason of your app crash is memory leaks in your code. 应用程序崩溃的最可能原因是代码中的内存泄漏。 Before doing anything make sure your connection are properly closed in finally block... 在执行任何操作之前,请确保您的连接已在finally块中正确关闭。

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

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