Profile Image

What is Garbage collection tuning: -XX:MaxHeapFreeRatio?

What is Garbage collection tuning: -XX:MaxHeapFreeRatio? Have you used this JVM argument before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvm-argument

  • xx-maxheapfreeratio

  • x-maxheapfreeratio

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky



-XX:MaxHeapFreeRatio=<maximum>, where maximum – is maximum proportion of free space at each collection. Its total size is bound by –Xmx<max> value.




Set maxHeapFreeRatio to 80%:


java -XX:MaxHeapFreeRatio=80




Different options affects generation size. During initialization of the JVM, the entire space for the heap is reserved. The size of the reserved space can be specified with the -Xmx option. If the value of the -Xms parameter is smaller than the value of the -Xmx parameter, then not all of the space that's reserved is immediately committed to the virtual machine. The uncommitted space is called “virtual”. The different parts of the heap, so called old and young generations, can grow to the limit of the virtual space as needed.


Default Value:


Default value for -XX:MaxHeapFreeRatio is dependent on JVM, for instance default option for the 64-bit Solaris operating system (SPARC Platform Edition) is 70, meaning that if the free space exceeds 70%, then the generation contracts so that only 70% of the space is free, subject to the minimum size of the generation.




Should be greater or equals to the value set in -XX:MinHeapFreeRatio


Arguments related:


TODO link MinHeapFreeRatio, Xmx, Xms


Related Posts;



If you have additional comments, interesting experiences or even point of disagreement with this JVM argument description, please leave a comment. Your insights will help the entire 10+ million java developer community to develop one standard source of documentation for all the JVM arguments.

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvm-argument

  • xx-maxheapfreeratio

  • x-maxheapfreeratio