C3P0 Creating too many threads and timers

I have a Java webapp running on Tomcat with Hibernate and C3P0. All entity classes and JPA controllers were run using NetBeans wizzard. There is a servlet that, when called, inserts many objects into the database (using JPA controllers).

The problem is that looking at my webapp with Java VisualVM, I found that there are many Timers and com.mchange.v2.async.ThreadPoolAsynchronousRunner classes, and it grows over time. For each timer, 3 threads are created.

All threads and timers are in WAIT state, and I think that this problem may be due to the OutOfMemory (Java Heap Space) error that the application has. produces. And although I see with the MySQL administrator that all connections are closed when the servlet completes the task, there may be some objects still in memory.

Is it normal for C3P0 to produce more than 700 leaves and 2,100 threads in the WAIT state?

thanks

Ezekuel

+4
source share
1 answer

Since you did not send any code, I can only guess, but it sounds very much like you are creating a lot of pools. You need to make sure that you are actually using one pool instead of creating it every time you need a connection.

The same thing happened to me once (by accident). Although I did not encounter OutOfMemory, I reached the maximum connection limit on the database server.

-2
source

All Articles