milind_db
milind_db

Reputation: 1294

Why I am getting memory leak exception after c3p0 configuration?

I am using java , GWT, and hibernate with 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:

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:

<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..

Upvotes: 1

Views: 1700

Answers (3)

Mahesh More
Mahesh More

Reputation: 929

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...

Upvotes: 0

Ingo Kegel
Ingo Kegel

Reputation: 48070

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.

Upvotes: 2

Marko Topolnik
Marko Topolnik

Reputation: 200216

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.

Upvotes: 2

Related Questions