Reading memory evidence at the right boundary
medium 6 minVirtual size includes mapped ranges whether or not their pages are resident.
Video lesson · Chapter 1 of 8
Why adding up worker RSS overcounts
Theory
Read or listen first. About 1 min.
What it is
Virtual size includes mapped ranges whether or not their pages are resident. RSS measures resident pages seen through one process. Summing RSS across workers counts a shared page repeatedly. Proportional set size divides shared pages among their mappings, while cgroup accounting measures the group’s charge under a different set of rules.
Why it exists
A prefork service triples its worker count and the RSS sum jumps. Before buying RAM compare proportional and private dirty memory, node availability, cgroup usage and pressure. Similar shared mappings can account for most of the apparent growth. Repeat after workers mutate shared pages because copy-on-write can turn that apparent cost into real private memory.
If private dirty pages and the group charge grow with tenant churn, investigate retained mutable data instead of shared mappings.
Why adding up worker RSS overcounts
Inside this chapter
- Memory Analysis with free and vmstat
- Available memory estimates how much can be used without swapping under current conditions. Vmstat samples activity over time, including paging and runnable work. Compare interval rows rather than only a boot average.
- Process Memory Maps with pmap
- A mapping list breaks a process down into anonymous regions, stacks and file-backed segments. Large mapped size alone does not show how many pages have been touched.
- Understanding /proc/meminfo
- Meminfo distinguishes several classes of memory, including file cache, dirty pages and reclaimable slab. Some fields overlap, so adding every line yields a meaningless total.
- Buffers vs Cache in Linux Memory
- Buffer and page caches serve kernel and file I/O. Some cached memory can be reclaimed. The cost depends on whether pages are clean, dirty or still actively used.
How it works
Step through the idea, or press Play.
Map the worker. Separate file-backed segments, stack and heap in one process.
Understand it
Worked incident
Why adding up worker RSS overcounts
| Observation | Sum of worker RSS (MiB) | Interpretation |
|---|---|---|
| Baseline | 200 | A single worker maps the shared dataset. |
| Incident | 600 | Three workers report the same resident shared pages in their own totals. |
| After intervention | 220 | Compare PSS and the group charge, then right-size the worker pool and watch private growth. |
Choose the next investigation
Summary
The whole topic in one minute.
PSS divides each shared page across its mappings. The group’s actual charge and pressure provide an independent operational check.
If private dirty pages and the group charge grow with tenant churn, investigate retained mutable data instead of shared mappings.