title: Shrinking survivor spaces lead to continuous full GC
body: <p>I've had this troubling experience with a Tomcat server, which runs:</p>
  
  <ul>
  <li>our <a href="http://java.net/projects/hudson/" rel="nofollow noreferrer">Hudson</a> server;</li>
  <li>a staging version of our web application, redeployed 5-8 times per day.</li>
  </ul>
  
  <p>The problem is that we end up with continuous garbage collection, but the old generation is nowhere near to being filled. I've noticed that the survivor spaces are next to inexisting, and the garbage collector output is similar to:</p>
  
  <pre><code>[GC 103688K-&gt;103688K(3140544K), 0.0226020 secs]
  [Full GC 103688K-&gt;103677K(3140544K), 1.7742510 secs]
  [GC 103677K-&gt;103677K(3140544K), 0.0228900 secs]
  [Full GC 103677K-&gt;103677K(3140544K), 1.7771920 secs]
  [GC 103677K-&gt;103677K(3143040K), 0.0216210 secs]
  [Full GC 103677K-&gt;103677K(3143040K), 1.7717220 secs]
  [GC 103679K-&gt;103677K(3143040K), 0.0219180 secs]
  [Full GC 103677K-&gt;103677K(3143040K), 1.7685010 secs]
  [GC 103677K-&gt;103677K(3145408K), 0.0189870 secs]
  [Full GC 103677K-&gt;103676K(3145408K), 1.7735280 secs]
  </code></pre>
  
  <p>The heap information before restarting Tomcat is:</p>
  
  <pre><code>Attaching to process ID 10171, please wait...
  Debugger attached successfully.              
  Server compiler detected.                    
  JVM version is 14.1-b02                      
  
  using thread-local object allocation.
  Parallel GC with 8 thread(s)         
  
  Heap Configuration:
     MinHeapFreeRatio = 40
     MaxHeapFreeRatio = 70
     MaxHeapSize      = 3221225472 (3072.0MB)
     NewSize          = 2686976 (2.5625MB)   
     MaxNewSize       = 17592186044415 MB    
     OldSize          = 5439488 (5.1875MB)   
     NewRatio         = 2                    
     SurvivorRatio    = 8                    
     PermSize         = 21757952 (20.75MB)   
     MaxPermSize      = 268435456 (256.0MB)  
  
  Heap Usage:
  PS Young Generation
  Eden Space:
     capacity = 1073479680 (1023.75MB)
     used     = 0 (0.0MB)
     free     = 1073479680 (1023.75MB)
     0.0% used
  From Space:
     capacity = 131072 (0.125MB)
     used     = 0 (0.0MB)
     free     = 131072 (0.125MB)
     0.0% used
  To Space:
     capacity = 131072 (0.125MB)
     used     = 0 (0.0MB)
     free     = 131072 (0.125MB)
     0.0% used
  PS Old Generation
     capacity = 2147483648 (2048.0MB)
     used     = 106164824 (101.24666595458984MB)
     free     = 2041318824 (1946.7533340454102MB)
     4.943684861063957% used
  PS Perm Generation
     capacity = 268435456 (256.0MB)
     used     = 268435272 (255.99982452392578MB)
     free     = 184 (1.7547607421875E-4MB)
     99.99993145465851% used
  </code></pre>
  
  <p>The relevant JVM flags passed to Tomcat are:</p>
  
  <pre><code>-verbose:gc -Dsun.rmi.dgc.client.gcInterval=0x7FFFFFFFFFFFFFFE -Xmx3g -XX:MaxPermSize=256m
  </code></pre>
  
  <p>Please note that the survivor spaces are sized at about 40 MB at startup.</p>
  
  <p>How can I avoid this problem?</p>
  
  <hr>
  
  <p><strong>Updates:</strong></p>
  
  <p>The JVM version is</p>
  
  <pre><code>$ java -version
  java version "1.6.0_15"
  Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
  Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02, mixed mode)
  </code></pre>
  
  <p>I'm going to look into bumping up the <code>PermGen</code> size and seeing if that helps - probably the sizing of the survivor spaces was unrelated.</p>