This continues kind of this question
I am making the same steps as there, but this time, I am dropping UseCGroupMemoryLimitForHeap
:
java -XX:InitialRAMPercentage=50.0 -XX:MaxRAMPercentage=50.0 -XX:+AlwaysPreTouch Dummy &
And I am trying to inspect it a little:
jcmd 279 VM.flags
Among other things, I see :
-XX:InitialHeapSize=2063597568
-XX:InitialRAMPercentage=50.000000
-XX:MaxRAMPercentage=50.000000
-XX:MaxHeapSize=2063597568
From a recommendation from this answer from Pangin, he says that:
-XX:InitialRAMPercentage is used to calculate initial heap size when InitialHeapSize / -Xms is not set.
and :
... both -XX:MaxRAMPercentage and -XX:MinRAMPercentage are used to calculate maximum heap size when MaxHeapSize / -Xmx is not set
My understanding that I should not set InitialHeapSize/Xms
and MaxHeapSize/Xmx
and I don't, but they are set for me.
I thought that I could say -XX:InitialHeapSize=0
and -XX:MaxHeapSize=0
, but of course this does not work and the VM does not start.
The last point is that :
top -o %MEM
shows a 2GB of resident memory for the java process, so yeah, both InitialRAMPercentage/MaxRAMPercentage
seems to be pointless?
The interesting thing here is that if I run this in jdk-17
:
java -XX:InitialRAMPercentage=50.0 -XX:MaxRAMPercentage=50.0 -XX:+AlwaysPreTouch Dummy &
then top -o %MEM
shows 1GB
, exactly like I want it to be.