title: Java 17 process running out of memory on Kubernetes when memory potentially available
body: <p>The goal is to understand what should be tuned in order for the Java process to stop restarting itself.</p>
  <p>We have a Java Springboot backend application with Hazelcast running that restarts instead of garbage collecting.<br />
  Environment is:</p>
  <blockquote>
  <p>Amazon Corretto 17.0.3</p>
  </blockquote>
  <p>The only memory tuning parameter supplied is:</p>
  <blockquote>
  <p>-XX:+UseContainerSupport -XX:MaxRAMPercentage=80.0</p>
  </blockquote>
  <p>The memory limit in kubernetes is 2Gi so the container gets 1.6Gi</p>
  <p>Graphs of memory usage:</p>
  <p><a href="https://i.stack.imgur.com/7PGI1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7PGI1.png" alt="Heap" /></a></p>
  <p><a href="https://i.stack.imgur.com/QUf8n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QUf8n.png" alt="Eden" /></a></p>
  <p><a href="https://i.stack.imgur.com/0KQSB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0KQSB.png" alt="Old Gen" /></a></p>
  <p>The huge drop towards the end is where I performed a heap dump.  Performing the dump lead to a drastic decrease in memory usage (due to a full GC?).</p>
  <p><a href="https://i.stack.imgur.com/9UPeN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9UPeN.png" alt="Heap dump results" /></a></p>
  <p>The GC appears to be working against me here. If the memory dump was not performed, the container hits what appears to be a memory limit, it is restarted by kubernetes, and it continues in this cycle.  Are there tuning parameters that are missed, is this a clear memory leak (perhaps due to hazelcast metrics) <a href="https://github.com/hazelcast/hazelcast/issues/16672" rel="nofollow noreferrer">https://github.com/hazelcast/hazelcast/issues/16672</a>)?</p>