title: Why is OpenJDK 11 Java garbage collector *decreasing* free memory in this sample program?
body: <p>When I compile and run the following very simple Java program using OpenJDK 11 (Zulu distribution on Windows 10):</p>
  
  <pre><code>public class GCTest {
      public static void main(String[] args) {
          System.out.println("Free memory before garbage collection: " + Runtime.getRuntime().freeMemory());
          Runtime.getRuntime().gc();
          System.out.println("Free memory  after garbage collection: " + Runtime.getRuntime().freeMemory());
      }
  }
  </code></pre>
  
  <p>it looks like garbage collection is <em>decreasing</em> the amount of free memory:</p>
  
  <pre><code>Free memory before garbage collection: 266881496
  Free memory  after garbage collection: 7772200
  </code></pre>
  
  <p>This does not happen when I run it with Oracle's Java 8:</p>
  
  <pre><code>Free memory before garbage collection: 254741016
  Free memory  after garbage collection: 255795064
  </code></pre>
  
  <p>Why is that?</p>