leponceau.org

Programming And Stuff, You Know The Thing…

Java 8 Garbage Collectors Do Not Release RAM to Host OS Voluntarily Any More

Posted at — Oct 2, 2017

I repeated the tests described over there and the result is that in contrast to Oracle’s Java 7 HotSpot VM, the Java 8 VM does not release any unused memory to the host OS any more without explicitly calling System.gc().

$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

The used startup arguments were:

-XX:+UseParallelGC -Xms16M -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10
-XX:+UseConcMarkSweepGC -Xms16M -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10
-XX:+UseG1GC -XX:GCTimeRatio=1 -Xms16M -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10
-XX:+UseSerialGC -Xms16M -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10

The tests were done on a 16 GB Linux machine, and your mileage certainly varies when your free RAM gets low. In my case, the RAM used by each process was pretty much constant around 1 GB.