Skip to content

Why free reports 16 GB

The situation

A Java service runs in a container with a 512 MB memory limit. It is killed and restarted every few hours.

The logs show no exception, no stack trace and no shutdown message. The container simply stops, and the exit code is 137.

Inside the container, free -m reports 16 GB of memory available. The JVM, reading that figure, has sized its heap accordingly and grows past 512 MB.

The host has 16 GB in total and is otherwise idle, so there is genuinely plenty of memory on the machine.

Why does a container limited to 512 MB report 16 GB of memory?