Hi! I'm building a web app in Tomcat using Hibernate. My Hibernate session is in a threadLocal variable, so there should be one session for each thread. It seems that Tomcat threads terminate from time to time and so more and more Hibernate sessions are being created over time. Another issue is that with each undeploy / deploy cycle when debugging the memory usage of tomcat increases, until finally I get an out of memory error.
I suspect that the cause of the problem is that the old hibernate sessions are not freed from memory. How can I do that? Or is it generally a bad idea to have threadLocal hibernate session in a tomcat web application? How can I do it better?
Thanks for your answers
Bastian Voigt
|