-
-
Notifications
You must be signed in to change notification settings - Fork 311
Description
The computation for memory usage is incorrect in
Line 18 in 7a98d42
| freeMem=`awk '/MemAvailable/ { print int($2/1024) }' /proc/meminfo` |
as that will give the system's memory rather than the container's limit memory.
In fact with newer JDKs there's no need to set it explicitly, instead you can let it compute it automatically. But don't that's also not good as it defaults to 25% of RAM that is allocated by default.
Instead specify the percentage usually 80% is good. -XX:MaxRAMPercentage=80
Here's how I used it https://github.com/trajano/spring-cloud-demo/blob/12deda06f3fb9c4101b4d4cf3c623a3001bd10d8/Dockerfile#L45
However, this would need to have an upgrade of the JDK as JDK8 does not support the parameter.
A workaround to this would be to use /sys/fs/cgroup/memory/memory.limit_in_bytes
You can verify this by
docker run --memory=1g --entrypoint /bin/cat -it justb4/jmeter /sys/fs/cgroup/memory/memory.limit_in_bytes