If I run a Java application using jre 8u74 on Linux using -Xmx512m, then the memory will not be allocated immediately, but the memory will be allocated if Java needs it. Thus, it can remain below the 512 MB limit if it is not necessary. This is what I would expect.
In Java 8u111, I get a different behavior, 512 MB of memory is always allocated directly to the process, even if it does not need Java. This is annoying because this memory cannot be used by other processes, even if it does not need Java.
I looked at the latest Java jre release notes from 8u74 to the current new 8u111, but I can’t find a link to change the memory allocation strategy.
Can someone confirm a change in distribution strategy within the Java 8 range? Is it possible to have previous memory allocation behavior?
Edit 1 - -XX: + Print FlagsFinal diff (as suggested by the8472)
diff java-info-8u111.txt java-info-8u74.txt
161d160
< bool CrashOnOutOfMemoryError = false {product}
199d197
< bool ExitOnOutOfMemoryError = false {product}
636d633
< bool UseCountedLoopSafepoints = false {C2 product}
666,668d662
< bool UseMontgomeryMultiplyIntrinsic = false {C2 product}
< bool UseMontgomerySquareIntrinsic = false {C2 product}
< bool UseMulAddIntrinsic = false {C2 product}
698d691
< bool UseSquareToLenIntrinsic = false {C2 product}
729,731c722,724
< java version "1.8.0_111"
< Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
< Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
---
> java version "1.8.0_74"
> Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
> Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
Change 2 - related issues
Change 3 - Solution
The problem is with the combination of Java8 / 9 and Jetty9. The workaround is to comment on the contents of the Jetty.mod annotation. See My complete answer to this related question.
Thanks for all the suggestions and new debugging ideas.