Skip to content

Incorrect computation for the memory #68

@trajano

Description

@trajano

The computation for memory usage is incorrect in

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions