Will Java 8 always consume at least 1GB of RAM by default when running inside a container?
in case of running inside container, where reserved memory becomes committed
No, reserved memory does not "become committed". The Virtual Size and the Resident Set Size are different metrics, whether in a container or not. What sits in the physical memory is RSS.
kubectl top
does not show you the RSS, but rather so-called "working set", which does not always match the real memory usage.
Does this mean that Java running in a container will by default consume at least 1GB of RAM?
No.
is there any other way to deal with that
It depends on your goals. If you'd like to see the actual container memory statistics, look at /sys/fs/cgroup/memory/.../memory.stats
and memory.usage_in_bytes
. Or if you use docker, run docker stats
.
If you'd like to decrease the process' virtual memory instead, turn off -XX:-UseCompressedClassPointers
.