You forked a process. Did you copy all its memory?
Copy-on-Write, page faults and why summed RSS misleads
Fork can share private physical pages until writes separate them. Count distinct dirtied pages and distinguish RSS from PSS.
A process uses virtual addresses. Page tables map them to physical memory, so the same numerical address in two processes does not prove that both refer to the same physical bytes.
Linux fork initially gives a child the parent's memory contents. For ordinary private mappings, Copy-on-Write can share physical pages while preserving each process's private view.
Pay for a copy when it becomes necessary
A write to a still-shared COW page triggers a page fault. The kernel can allocate a new page, copy the contents and update the writer's mapping, then continue execution.
This fault is normal operation, not necessarily a crash. If sharing no longer requires a separate copy, a new allocation is not always necessary.
The copy unit is a page, not the variable changed. Writing one byte can separate a whole page. We use 4 KiB pages below as an illustrative assumption, not a universal Linux page size.
Four workers and one catalog
An initialized parent holds 64 MiB of ordinary private resident pages and forks four children. Ignore process, page-table and library overhead.
If all five processes only read those pages, the data can occupy 64 MiB physically rather than five full copies.
Each child then writes to 256 distinct, still-shared pages:
256 × 4 KiB = 1 MiB per child
Four children add 4 MiB, bringing this simplified catalog to about 68 MiB. A million later writes to one already-private page do not require a million further copies.
Why summed RSS misleads
RSS counts resident pages mapped by a process, including shared ones. Adding workers' RSS may count the same pages repeatedly.
PSS apportions shared pages across their users. Before writes, the isolated catalog contributes about 12.8 MiB PSS to each of the five processes while each can report 64 MiB RSS for it. These are not the whole process's memory figures.
Real runtimes, huge pages and changing mappings complicate the picture. Measure after warm-up under realistic load; do not estimate physical use by multiplying one worker's RSS.
Private sharing is not communication
COW preserves isolation. A child's write to private memory does not update the parent's view.
MAPPRIVATE file mappings likewise do not write private changes back to the file or update other mappings. MAPSHARED is a different contract and needs synchronization; shared does not mean atomic or crash-durable.
On Linux, run this as a separate program, not inside a multithreaded server:
The child prints B and the parent A. This demonstrates isolation, not a direct count of copied physical pages.
Check yourself
If each child separates 1,024 pages instead, the simplified additional memory is 16 MiB and the catalog totals about 80 MiB. Runtime bookkeeping can also dirty pages, even when application code considers an object read-only.