title: How to detect a low heap situation for monitoring and alerting purposes?
body: <p>We monitor our production JVMs and have monitoring triggers that (ideally) send warnings, when the JVM runs low on heap space. However, coming up with an effective detection algorithm is quite difficult, since it is the nature of garbage collection, that the application regularly has no available memory, before the GC kicks in.</p>
  
  <p>There are many ways to work around this, I can think of. E.g. monitor the available space, send a warning when it becomes too low, but delay it and only trigger, when it is persistent for more than a minute. So, what works for you in practice?</p>
  
  <p>Particular interesting:</p>
  
  <ul>
  <li>How to detect a critical memory/heap problem, that needs immediate reaction?</li>
  <li>How to detect a heap problem, that needs a precaution action?</li>
  <li>What approaches work universally? E.g. without the need to adapt the triggers to certain JVM tuning parameters or vice versa, or, force a GC in certain time intervals. </li>
  <li>Is there any best practice that is used widely?</li>
  </ul>