-Xmx
specifies the precise upper limit for the heap. It is the preferred way to set the heap size.
-XX:MaxRAM
does not define the heap size directly. Instead this parameter overrides the actual amount of physical RAM when calculating the heap limits basing on ergonomics.
If -Xmx
is set, MaxRAM
is never used. Otherwise the maximum heap size is estimated1 as
MaxHeapSize = MaxRAM * MaxRAMPercentage / 100% (default MaxRAMPercentage=25)
1 The actual algorithm is a bit more complicated and depends on other parameters.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…