title: Reducing JVM pause time > 1 second using UseConcMarkSweepGC
body: <p>I'm running a memory intensive app on a machine with 16Gb of RAM, and an 8-core processor, and Java 1.6 all running on CentOS release 5.2 (Final).  Exact JVM details are:</p>
  
  <pre><code>java version "1.6.0_10"
  Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
  Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)
  </code></pre>
  
  <p>I'm launching the app with the following command line options:</p>
  
  <pre><code>java -XX:+UseConcMarkSweepGC -verbose:gc -server -Xmx10g -Xms10g ...
  </code></pre>
  
  <p>My application exposes a JSON-RPC API, and my goal is to respond to requests within 25ms.  Unfortunately, I'm seeing delays up to and exceeding 1 second and it appears to be caused by garbage collection.  Here are some of the longer examples:</p>
  
  <pre><code>[GC 4592788K-&gt;4462162K(10468736K), 1.3606660 secs]
  [GC 5881547K-&gt;5768559K(10468736K), 1.2559860 secs]
  [GC 6045823K-&gt;5914115K(10468736K), 1.3250050 secs]
  </code></pre>
  
  <p>Each of these garbage collection events was accompanied by a delayed API response of very similar duration to the length of the garbage collection shown (to within a few ms).</p>
  
  <p>Here are some typical examples (these were all produced within a few seconds):</p>
  
  <pre><code>[GC 3373764K-&gt;3336654K(10468736K), 0.6677560 secs]
  [GC 3472974K-&gt;3427592K(10468736K), 0.5059650 secs]
  [GC 3563912K-&gt;3517273K(10468736K), 0.6844440 secs]
  [GC 3622292K-&gt;3589011K(10468736K), 0.4528480 secs]
  </code></pre>
  
  <p>The thing is that I thought the UseConcMarkSweepGC would avoid this, or at least make it extremely rare.  On the contrary, delays exceeding 100ms are occurring almost once a minute or more (although delays of over 1 second are considerably rarer, perhaps once every 10 or 15 minutes).</p>
  
  <p>The other thing is that I thought only a FULL GC would cause threads to be paused, yet these don't appear to be full GCs.</p>
  
  <p>It may be relevant to note that most of the memory is occupied by a LRU memory cache that makes use of soft references.</p>
  
  <p>Any assistance or advice would be greatly appreciated.</p>