C3P0 Creating too many Threads and Timers

假如想象 提交于 2019-12-23 12:58:13

问题


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

The problem is that looking at my webapp with Java VisualVM I found that there are a lot of Timers and com.mchange.v2.async.ThreadPoolAsynchronousRunner classes, and it grows as time pass. For every Timer there are 3 Threads created.

All the Threads and Timers are in WAIT state, and I think that this problem may be behind an OutOfMemory error (Java Heap Space) that the app. produces. And even though I see at MySQL Administrator that all the connections are closed when the servlet ends the task, may be some objects are still in memory.

Is it normal that C3P0 creates leaves more than 700 Timeras and 2100 Threads in "WAIT" state?

Thanks

Ezequiel


回答1:


As you did not post any code, I can only guess, but it sounds pretty much like you're creating lots of pools. You should make sure, that you actually reuse one pool instead of creating one each time you need a connection.

Same thing happened to me once (accidentally). Though I did not ran into OutOfMemory, but reached the max-connection-limit on the database-server.



来源:https://stackoverflow.com/questions/6651263/c3p0-creating-too-many-threads-and-timers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!