title: java server with jetty memory leak issue
body: <p>I´m running this application with a Jetty server embedded. The application is slowly consuming more memory dispite the fact that the heap size does not change at all.</p>
  
  <p>this is the command to start the application :</p>
  
  <p>java -server -Xms1G -Xmx1G -Dfile.encoding=UTF-8 </p>
  
  <p>This is the chart from new relic with the RAM usage increase
  <a href="https://i.stack.imgur.com/EU1Un.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EU1Un.png" alt="enter image description here"></a>
  it started using 1140MB and after 8 hours finished with 1290MB </p>
  
  <p>This is the jvisualvm chart of the heap.
  <a href="https://i.stack.imgur.com/dBOun.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dBOun.png" alt="enter image description here"></a></p>
  
  <p>Any suggestions ?</p>
  
  <p>[EDIT1] 
  add dump <a href="https://www.dropbox.com/s/1gt1i9dhjtjauf0/gameserver-20160226-2107.zip?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/1gt1i9dhjtjauf0/gameserver-20160226-2107.zip?dl=0</a></p>
  
  <p>[EDIT2]
  Here are some notes from my current investigation </p>
  
  <p>= How Monitor memory outside the heap
  add parameters </p>
  
  <pre><code>-XX:NativeMemoryTracking=detail -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMTStatistics
  </code></pre>
  
  <p>run command
  jcmd 3322 VM.native_memory summary
  @see <a href="https://devcenter.heroku.com/articles/java-memory-issues" rel="nofollow noreferrer">https://devcenter.heroku.com/articles/java-memory-issues</a></p>
  
  <p>= Checking the default thread stack size 
  java -XX:+PrintFlagsFinal -version | grep ThreadStackSize</p>
  
  <blockquote>
    <blockquote>
      <p>intx ThreadStackSize                           = 1024<br>
      <a href="https://stackoverflow.com/questions/1479214/how-to-reclaim-the-memory-used-by-a-java-thread-stack">How to reclaim the memory used by a Java thread stack?</a></p>
    </blockquote>
  </blockquote>
  
  <p>= Understand the max memory
  Max memory = [-Xmx] + [-XX:MaxPermSize] + number_of_threads * [-Xss]
  @see <a href="https://plumbr.eu/blog/memory-leaks/why-does-my-java-process-consume-more-memory-than-xmx" rel="nofollow noreferrer">https://plumbr.eu/blog/memory-leaks/why-does-my-java-process-consume-more-memory-than-xmx</a></p>
  
  <p>= Actions 
  Reduce the size of the thread stacks. (In theory, you can go as low as 64K ...)</p>
  
  <pre><code>-XX:ThreadStackSize=256
  </code></pre>
  
  <p>Reduce the Minimum percentage of heap free after GC to avoid expansion.</p>
  
  <pre><code>-XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=10
  </code></pre>
  
  <p>Now will continue monitoring ...</p>