title: Java 17 app shows very high RAM usage in docker
body: <p>I have a application that during idle times usually only needs 1GB of RAM however when I launch it inside in docker, then it shows much higher RAM usage (5GB) from the outside.
  The JVM metric show that I still only use ~1GB of RAM, but the JVM does not really release any RAM it ever claimed.
  I cannot reduce the RAM limits (~8GB using MaxRamPercentage), as it needs it during high load, startup, and some special events. I could periodically call <code>System.gc()</code> as that frees and releases a lot of memory, but the RAM shoots back up to where it was after a few requests. This claiming of unused RAM wastes a lot of resources and causes OOMs on the server as none of the applications release their memory.</p>
  <p>According to this <a href="https://openjdk.java.net/jeps/346" rel="nofollow noreferrer">JEP-346</a> the &quot;bug&quot; has been fixed, that caused the garbage collector to not release the memory, but I don't see any improvements.</p>
  <p>For testing purposes, I also tried using the <code>-XX:+UseShenandoahGC</code> and it releases the memory as expected. But during startup it takes almost all the RAM which causes issues during server/multiple simultaneous application restarts.</p>
  <p><strong>TLDR:</strong> Actually used RAM ~1 GB, claimed RAM ~5 GB, RAM Limit ~8GB.
  The default GC does not release enough RAM, without explicitly calling System.gc().
  Is the G1 GC the default GC in Java 17? (AFAICT it is)
  Are there any parameters required to make the changes from <a href="https://openjdk.java.net/jeps/346" rel="nofollow noreferrer">JEP-346</a> work as expected?</p>