docker-jmeter icon indicating copy to clipboard operation
docker-jmeter copied to clipboard

Incorrect computation for the memory

Open trajano opened this issue 1 year ago • 0 comments

The computation for memory usage is incorrect in https://github.com/justb4/docker-jmeter/blob/7a98d4207ce88f5be06a0963690de891e4bae1d4/entrypoint.sh#L18

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

trajano avatar Oct 09 '22 03:10 trajano