title: Extremely long garbage collection times
body: <p>We have a web application running Java 6, Tomcat 6, Spring Framework 3, Hibernate 4, EhCache.
  We have a problem with extremely long garbage collection times which can take 30 seconds or longer, leaving the application unresponsive. </p>
  
  <p>We're currently in testing but apart from the obvious: add more memory, I was wondering if there are aspects we could tune to reduce garbage collection time. </p>
  
  <p>The major contributor to memory use is EHCache as we are aggressively caching. But I always find it hard to size the EHCache stores (the new EhCache byte size stores, lead to all sorts of problems with us because the cached object graphs can be quite large). </p>
  
  <p>These are my settings for the JVM</p>
  
  <pre><code>JAVA_OPTS="$JAVA_OPTS -server -Xms256m -Xmx704m XX:OnOutOfMemoryError=/usr/share/scripts/on_server_crash.sh -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/tomcat6 -XX:MaxPermSize=192m -XX:+UseConcMarkSweepGC
  </code></pre>