Observation and diagnostics · Intermediate

Reading Linux memory with /proc/meminfo

Distinguish free memory, reclaimable uses, and process residency when investigating memory pressure on Linux.

Ask Logeia about this articleTry the three questionsReview your answers

Updated

On this page
  1. Identify which memory question you are asking
  2. Do not diagnose pressure from MemFree alone
  3. Connect the system view to process mappings
  4. Add time and resource limits to the diagnosis
  5. Ask Logeia about this articleCheck your understanding

Identify which memory question you are asking

The /proc/meminfo file reports system memory statistics, not a list of allocations belonging to one application. Separate questions about the whole machine, a growing process, and a container approaching its limit. These are related observations, but they do not have the same scope or require the same files.

MemTotal describes usable physical memory. Reserved regions mean it need not equal the nominal capacity printed on a memory module. Preserve units and avoid substituting this physical quantity for virtual-address-space size or the total number of bytes requested by application allocation calls.

Do not diagnose pressure from MemFree alone

A small MemFree value does not by itself prove memory exhaustion. Physical memory also supports uses such as file caching that may be reclaimed. MemAvailable estimates capacity for new applications without swapping and therefore incorporates more information than the amount currently sitting unused.

For a hypothetical eight-GiB machine, MemFree of 256 MiB alongside roughly three GiB of MemAvailable should not be summarized as only 256 MiB being usable. This illustration is not a capacity guarantee. Some fields overlap or describe subdivisions, so adding every cache, slab, and activity field does not reconstruct a meaningful total.

Connect the system view to process mappings

Start with the system file, then investigate status or smaps for a suspected process. Replace 1234 in the example with the process being observed. VmSize concerns virtual size while VmRSS concerns residency; a difference between them is expected for many legitimate mappings and is not itself evidence of a leak.

Summing RSS across processes can count shared physical pages more than once. PSS apportions shared mappings and can help answer a different accounting question. Inspect which mappings grow over time and distinguish retained application data from file-backed pages before proposing a change to allocation behavior.

shell
cat /proc/meminfo
# Replace 1234 with the PID being investigated.
cat /proc/1234/status
cat /proc/1234/smaps

Add time and resource limits to the diagnosis

One snapshot does not prove a leak or identify the cause of an OOM event. Align observations with workload, completed requests, swap activity, and process behavior. Ask whether memory is released or reused after the same work ends, and retain enough repeated observations to distinguish a temporary peak from sustained growth.

A container can hit its cgroup limit while the host still has available memory. With cgroup v2, inspect memory.current, memory.max, and relevant memory.events in the process’s actual group. The host-level memory file alone cannot establish the container’s remaining allowance, so identify both the scope and the limiting boundary.

Reading and practice are recorded separately in this browser, for each language.

Learn this in order

Build your CS foundations · STEP 4

Understand the systems behind the web · STEP 2

Prepare for AI systems · STEP 3

Choose a learning path