title: Memory leak in Hibernate session?
body: <p>I am experiencing a memory leak in a Hibernate session. </p>
  
  <p>A long running thread is continuously loading and updating data. While the thread regularily calls <code>entityManager.clear()</code> I observe both: </p>
  
  <p>1.) growth in <code>Session</code>-size (linear growth since start of application)</p>
  
  <p>2.) growth in execution-time (exponential growth since start of application)</p>
  
  <p>The only thing, that seems to help is to <code>close()</code> the entitymanager and re-open it. I have seen this behaviour in several unconnected applications, some with spring, some without, some using the jpa-frontend, some using hibernate natively.</p>
  
  <p>Weird enough: while I have never encountered a hibernate application without this problem, searching the internet comes up blank. What am I (and dozens of other developers) doing wrong?</p>