Dirty vs resident vs virtual memory?
Four metrics
- Virtual — the whole range of virtual addresses the process has reserved: every segment of the binary and dylibs, the shared cache, stacks,
mallocregions,mmap'd files. On a 64-bit system that is gigabytes "on paper" (addresses are cheap) — the number tells you almost nothing. - Resident (RSS) — how much of that is physically in RAM right now. It includes pages that are not "yours": system framework code shared by every process, so RSS overstates the app's guilt.
- Dirty — pages the process has modified: heap, stacks, decoded images,
__DATAafter a write. They cannot be evicted because there is nothing to restore them from — only kept or compressed. - Compressed — dirty pages the memory compressor has squeezed and keeps in RAM in compressed form.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep