Part 1 of 7 · 1 min read
Why this page comes last in the level
In this module you will
- Say what
VmSize,VmRSSand the proportional set size mean, and why they differ. - Split a process's resident memory into anonymous, file-backed and shared parts.
- Find the biggest mappings of a process with
pmapand/proc/PID/smaps_rollup. - Tell a leak from a cache, from fragmentation and from a mapping that is large but idle.
- Follow a growing process from the symptom to the line of code that allocates the memory.
This page puts the level together. Page 1 described the heap, page 2 its bugs, page 3 the stack, page 4 mapped files, page 5 shared memory, page 6 huge pages and page 7 the limits. A real report arrives as one sentence: "the service uses 2 GiB and keeps growing". This page shows how to turn that sentence into an answer, using only the numbers that Linux gives for every process. The sources are TLPI chapters 6 and 7, the manual pages of proc and pmap, and the manual of Valgrind's Massif tool. The programs were compiled with gcc -O2 -Wall -Wextra and run on a Linux machine with 8 GiB of memory.
About this example About this example
Real: The facts, definitions and algorithms on this page come from the books named in the text. No program on this page was timed.
Scripted: The worked traces use small numbers chosen so they can be followed by hand.
Not real: The page simplifies real systems. Actual kernels add more cases, limits and tuning than a short page can show.