title: The Java ZGC garbage collector USES a lot of memory
body: <p>I built a simple application using Springboot.The ZGC garbage collector I use when deploying to a Linux server USES a lot of memory..I tried to limit the maximum heap memory to 500MB with Xmx500m, but the JAVA program still used more than 1GB. When I used the G1 collector, it only used 350MB.I don't know why, is this a BUG of JDK11?Or do I have a problem with my boot parameters?
  ####Runtime environment</p>
  <ul>
  <li><em>operating system</em>: <strong>CentOS Linux release 7.8.2003</strong></li>
  <li><em>JDK version</em>: <strong>jdk11</strong></li>
  <li><em>springboot version</em>: <strong>v2.3.0.RELEASE</strong>
  Here is my Java startup command</li>
  </ul>
  <pre class="lang-sh prettyprint-override"><code>java -Xms128m -Xmx500m \
  -XX:+UnlockExperimentalVMOptions -XX:+UseZGC \
  -jar app.jar
  </code></pre>
  <p><strong>Here is a screenshot of the memory usage at run time</strong></p>
  <p><em>Heap memory usage</em>
  <a href="https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20201259.png?raw=true" rel="noreferrer">https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20201259.png?raw=true</a></p>
  <p><em>System memory usage</em>
  <a href="https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20201357.png?raw=true" rel="noreferrer">https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20201357.png?raw=true</a></p>
  <hr />
  <p><strong>Here's what happens when you use the default garbage collector</strong>
  <em>Java startup command</em></p>
  <pre class="lang-sh prettyprint-override"><code>java -Xms128m -Xmx500m \
  -jar app.jar
  </code></pre>
  <p><em>Heap memory usage</em>
  <a href="https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20202442.png?raw=true" rel="noreferrer">https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20202442.png?raw=true</a></p>
  <p><em>System memory usage</em>
  <a href="https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20202421.png?raw=true" rel="noreferrer">https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20202421.png?raw=true</a></p>
  <p>By default jdk11 USES the G1 garbage collector. Theoretically, shouldn't G1 be more memory intensive than ZGC?Why didn't I use it that way?Did I misunderstand?Since I'm a beginner to the JVM, I don't understand why.</p>