Why do -Xmx and Runtime.maxMemory not agree

前端 未结 2 1801
温柔的废话
温柔的废话 2020-12-08 04:54

When you add

 -Xmx????m

to the command line, the JVM gives you a heap which is close to this value but can be out by up to 14%. The JVM c

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 05:38

    The following graph shows the Runtime.maxMemory as a percentage of Xmx (on the y-axis) for different Xmx values (on the x-axis).

    We see that for the most part only ~85% of the Xmx setting is available for the heap to grow. This analysis is conducted using java version "1.8.0_212" Java(TM) SE Runtime Environment (build 1.8.0_212-b10) Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)

    Graph of (maxMem/Xmx) for varying Xmx sizes (in MB)

提交回复
热议问题