Release java memory for OS at runtime

I have posted my test results over there. Basically, MaxHeapFreeRatio is not respected by every GC implementation, and, to make it worse, it seems to be necessary that there is enough heap activity in order to trigger it in a timely manner, ie. could be that you require 2 full GC runs to actually release the memory to the OS. And if you have a burst memory footprint of X GB, then you probably have to allocate 1 or 2 times of that amount in order to trigger the heap downsize. Or you call System.gc() manually.

If performance is not an issue, and memory footprint is all that counts, try:

-XX:UseSerialGC -Xms16M -Xminf=5 -Xmaxf=10

Leave a Comment