Skip to main content

Module mem_census

Module mem_census 

Source
Expand description

srv’s own memory, and what holds it: one report, logged every few minutes and served to muxspect memory.

Three things are read side by side, because the question on a machine where srv has grown large is which of them the memory is in:

  1. What the operating system has given the process (process).
  2. What srv has allocated and not freed (alloc). Committed memory far above this is memory the heap keeps after it was freed, and no structure holds it.
  3. The structures known to grow with use, each with its count and an estimate of its bytes (Held). Live bytes far above their sum is a structure this census does not know.

The bytes of a structure are an estimate: the content of its strings and JSON values plus the room its lists reserve, not the allocator’s rounding. Taking the census walks each structure under its own lock, one at a time; the report says how long that took.

Report: docs/reports/REPORT_SRV_MEMORY_UNDER_400MB_2026_12_01.md (step 0 of its plan).

Modules§

alloc
How much the process has allocated and not freed.
process
What the operating system says about this process: memory, threads, handles.

Structs§

Held
One structure that grows with use: how much it holds now.
MemReport
One reading of srv’s memory.

Constants§

FIRST_REPORT_AFTER
The first report comes this long after start, when the windows and agents are restored.
LOG_TARGET
The log line’s target: muxlog srv grep srv_mem.
REPORT_EVERY
Then one report per interval. The census walks every kept event, so it is not taken every few seconds; a day of use still gives 288 readings.

Functions§

collect
Take a reading. Blocking work (a walk of every counted structure, each under its own lock): call it from the blocking pool.
json_bytes
An estimate of the heap bytes behind a JSON value (not the Value itself, which its holder counts): string text, array slots and object entries, all the way down.
log
Write the reading as one log line.
subagent_event_bytes
An estimate of the heap bytes behind one subagent event.