Expand description
Per-task heap-allocation monitor for Copper.
CuMemMon consumes the CuMonitor::observe_alloc hook the runtime emits
around every task and bridge lifecycle step and reports:
- per-step allocation deltas (running totals + per-call peak),
- per-task lifetime balance (
alloc - deallocsince the task’sstart), - a throttled
[mem]one-liner fromprocess_copperlist, - a final per-task leak report at runtime shutdown.
Optional realtime-strict mode (realtime_strict: true in the monitor’s
RON config) latches any non-zero allocation observed during Preprocess,
Process, or Postprocess and surfaces it from the following
process_copperlist call as a CuError. In practice that is the very same
iteration’s process_copperlist (it runs after all the step hooks), so the
violation aborts the run within the same tick it occurred in. The runtime
treats the returned error as a fatal monitor error and shuts down cleanly
— unrelated task errors are not escalated by this path. The first violating
step in a copperlist wins (later violations in the same window are
observed but don’t overwrite the latched cause).
When the runtime is not built with cu29/memory_monitoring, the macro
emits no allocation scopes, so observe_alloc is never called. CuMemMon
detects this in two complementary ways:
- At
start()it probes the public counter API (cu29::monitoring::global_allocated_bytes). If that returnsNonethe runtime side is off and we warn immediately. - If the runtime side is on but no
observe_allocever fires (the macro side was built without the feature — possible when features are wired piecemeal instead of through thecu29umbrella), the first scheduled summary tick emits a one-shot warning.