Skip to main content

Crate cu_memmon

Crate cu_memmon 

Source
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 - dealloc since the task’s start),
  • a throttled [mem] one-liner from process_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 returns None the runtime side is off and we warn immediately.
  • If the runtime side is on but no observe_alloc ever fires (the macro side was built without the feature — possible when features are wired piecemeal instead of through the cu29 umbrella), the first scheduled summary tick emits a one-shot warning.

Structs§

CuMemMon