title: JVM heap used percentage - when to generate alert
body: <p>We have an application which is deployed on Tomcat 8 application server and currently monitoring server (Zabbix) is configured to generate alert if the heap memory is 90% utilized.</p>
  <p>There were certain alerts generated which prompted us to do heap dump analysis. Nothing really came out of heap dump, there was no memory leak. There were lot of unreachable object which were not cleaned up because of no GC.</p>
  <p><strong>JVM configurations:</strong></p>
  <pre><code>-Xms8192m -Xmx8192m -XX:PermSize=128M -XX:MaxPermSize=256m 
  -XX:+UseParallelGC -XX:NewRatio=3 -XX:+PrintGCDetails 
  -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/app/apache-tomcat-8.0.33 
  -XX:ParallelGCThreads=2 
  -Xloggc:/app/apache-tomcat-8.0.33/logs/gc.log 
  -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps 
  -XX:+PrintGCTimeStamps -XX:GCLogFileSize=50m -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=30
  </code></pre>
  <p>We tried running garbage collection manually using <code>jcmd</code> command and it cleared up the memory. GC logs after running <code>jcmd</code>:</p>
  <pre><code>2016-11-04T03:06:31.751-0400: 1974627.198: [Full GC (System.gc()) [PSYoungGen: 18528K-&gt;0K(2049024K)] [ParOldGen: 5750601K-&gt;25745K(6291456K)] 5769129K-&gt;25745K(8340480K), [Metaspace: 21786K-&gt;21592K(1069056K)], 0.1337369 secs] [Times: user=0.19 sys=0.00, real=0.14 secs]
  </code></pre>
  <p>Questions:</p>
  <ol>
  <li>Is there any configuration above due to which GC is not running automatically.</li>
  <li>What is the reason of this behavior? I understand that Java will do GC when it needs to. But, if it is not running GC even when heap is 90% utilized, what should be the alert threshold (and if it even makes sense to have any alert based on heap utilization).</li>
  </ol>