Expand description
Process memory instrumentation (§3.7): the numbers mem.sh reads from
/proc, available in-process and via synaps status --memory — no root,
no smem.
Linux only. Every entry point degrades to Unsupported / zeroed fields on
other platforms so callers never need their own cfg.
Structs§
- MemTotals
- Totals over a set of
ProcMemrows. - ProcMem
- One process’ memory, straight from
smaps_rollup+status. - SelfMem
- In-process snapshot: kernel view + jemalloc’s own accounting (zeros when the build does not link jemalloc-ctl).
Enums§
- Proc
Role - What a process in a session tree is, classified from its cmdline.
Functions§
- background_
threads_ enabled - Current
background_threadsetting (Nonewithout jemalloc). - classify
- Classify a process from its cmdline (argv joined by spaces) and, when known, the engine binary’s own name.
- disable_
thp prctl(PR_SET_THP_DISABLE)— no transparent huge pages for this process from now on. WithTHP=alwaysevery touched thread stack, the.bssand each jemalloc chunk costs a 2 MiB page; the thin client wants 4 KiB granularity. Inherited by threads created afterwards. Linux only.- ladder
- Boot-ladder stage (PLAN-phase4 §7.1): appends one line to the trace file
— not
tracing(the attach client has no subscriber) and not stderr (it is the TUI). No-op (one atomic load) unlessSYNAPS_MEM_TRACE=1. - log_
turn_ memory - One
agent_core::memstatinfo line (“turn memory”) — called atSessionEvent::Donesosynaps.logcarries a greppable per-turn memory trace. No-op (one atomic load) unlessSYNAPS_MEM_TRACE=1. - mem_
trace_ enabled SYNAPS_MEM_TRACE=1turns on the per-turn memory trace and the broker install log line. Read once; one atomic load per call afterwards.- process
- Memory of exactly one process (no descendants).
- purge_
arenas - Ask jemalloc to purge every arena’s dirty/muzzy pages back to the OS —
the manual
malloc_trimequivalent. No-op on builds without jemalloc. - redact_
cmdline - Scrub credentials out of a space-joined argv before it leaves the
process. Redacted: the value of any
--flag value/--flag=valuewhose flag name mentions key/token/secret/password/bearer/auth/credential, anyKEY=valueenv-style arg with such a key, and any bare arg that looks like a key (sk-…,ghp_…,xox…,Bearer …, or ≥ 32 chars of base64/hex with no path separator). - self_
snapshot - Kernel + allocator view of the calling process. Never fails; fields are zero where unavailable.
- set_
background_ threads background_threadon/off. Turning it off joins everyjemalloc_bg_thd(PLAN-phase4 §4.1) — call before spawning threads so none are created for the arenas they touch. No-opOkwithout jemalloc.- set_
decay_ ms - Decay times for existing arenas (
arena.<ALL>.*_decay_ms) and the default for future ones (arenas.*_decay_ms).0= purge a freed run on the next decay tick;-1= never. §4.2. - set_
thread_ tcache thread.tcache.enabledfor the calling thread (§4.3 fallback).- thp_
disabled prctl(PR_GET_THP_DISABLE)— is THP already off for this process (inherited acrossexecve, so a re-exec’d client seesSome(true))?- thp_
sysfs_ always - Kernel THP mode:
Some(true)when/sys/kernel/mm/transparent_hugepage/enabledis[always],Some(false)for[madvise]/[never],Nonewhen unreadable (non-Linux, no sysfs). - tree
- Walk
pidand every descendant (via/proc/*/statppid), readingsmaps_rollupandstatusfor each. Root first, then children in discovery order. Processes that vanish mid-walk are skipped.
Type Aliases§
- Mallctl
Result - Outcome of one mallctl write, for the ladder line (never fatal).