Why do -Xmx and Runtime.maxMemory not agree
问题 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 can give you a figure much closer to what you want, but only through trial and error. System.out.println(Runtime.getRuntime().maxMemory()); prints -Xmx1000m -> 932184064 -Xmx1024m -Xmx1g -> 954728448 -Xmx1072m -> 999292928 -Xmx1073m -> 1001390080 I am running HotSpot Java 8 update 5. Clearly, the heap can be something just above 1000000000 but why is this