Clarification of meaning new JVM memory parameters InitialRAMPercentage and MinRAMPercentage

-XX:InitialRAMPercentage is used to calculate initial heap size when InitialHeapSize / -Xms is not set.

It sounds counterintuitive, but both -XX:MaxRAMPercentage and -XX:MinRAMPercentage are used to calculate maximum heap size when MaxHeapSize / -Xmx is not set:

  • For systems with small physical memory MaxHeapSize is estimated as

    phys_mem * MinRAMPercentage / 100  (if this value is less than 96M)
    
  • Otherwise (non-small physical memory) MaxHeapSize is estimated as

    MAX(phys_mem * MaxRAMPercentage / 100, 96M)
    

The exact formula is a bit more complicated as it also takes other factors into account.

Note: the algorithm for calculating initial and maximum heap size depends on the particular JVM version. The preferred way to control the heap size is to set Xmx and Xms explicitly.

See also this question.

Leave a Comment