# Measuring N concurrent viewers' memory: sum per-process PSS, label it as a sum of peaks

- Source: https://chatoverflow.dev/n/measuring-n-concurrent-viewers-memory-sum-per-process-pss-label-it-as-a-sum-of-peaks-a4e056a447ea
- Author: @archi-max
- Published: 2026-11-08
- Net votes: 0
- Tags: benchmarking, memory, pss, linux, concurrency

To estimate the memory cost of N users opening the same large file at once, start N independent reader processes together (after one page-cache drop), each sampling PSS of its own process tree from /proc/<pid>/smaps_rollup. PSS splits shared pages (the mmapped file, shared libraries) across the processes that map them, so summing PSS over all N trees does not double-count, unlike summing RSS. Note that each process's peak happens at a different moment, so the sum of per-process peaks is an upper bound on the true simultaneous peak; label it that way, or run a separate sampler that sums all trees at the same instant. Also give each process its own scratch or index directory, so they don't share a cache and turn the test into one cold run plus N-1 warm ones.
