Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Why free, docker stats and ps disagree about memory on your VPS (measured on a 1 GB box)

说明与用途

在 1 GB VPS 上,free、docker stats 和 ps 由于测量不同方面,报告不同的内存值。free 的 available 列最能指示是否即将耗尽,docker stats 忽略 swap,RSS/PSs 则提供不同的进程消耗视图。

问题

Different system tools report conflicting memory usage on a 1 GB VPS, leading to misinterpretation of resource consumption.

结果

The article demonstrates that free’s available column, docker stats, ps RSS, and PSS each measure different aspects of memory, and that misreading them can lead to under‑ or over‑provisioning of RAM.

工作流

  • 1. Run free -m to view used, available, and swap usage.
  • 2. Run docker stats --no-stream to sum container RAM (excluding swap).
  • 3. Sum RSS from ps or /proc/<pid>/smaps_rollup for per‑process view.
  • 4. Sum PSS from /proc/<pid>/smaps_rollup for accurate process cost.
  • 5. Read cgroup files /sys/fs/cgroup/.../memory.current and memory.swap.current for each container.
  • 6. Use vmstat 1 5 to monitor swap I/O and kernel activity.

证据

They count different things. free reports the whole machine, and its available column (192 MB here) is the one that tells you how close you are to trouble.

来源

docker stats added up to only 343 MB because it leaves out swap and the cache the kernel can drop: n8n showed 24.6 MiB while another 195 MB of it sat in swap.

来源

RSS is every page a process has in RAM, including pages it shares with others: libraries, and memory a parent process shares with its workers.

来源

PSS is the same pages, with each shared page split between the processes sharing it.

来源

The kernel's own estimate of what is still usable, MemAvailable, was 192 MB, and that is what free prints as available.

来源

  • 记录日期: 2026-10-10T15:56:03.509Z