Skip to main content

Module guard

Module guard 

Source
Expand description

RAII guard returned by start() / start_with(); drops trigger exit export. MemScopeGuard — the RAII handle returned by start() / start_with().

Holding the guard keeps tracking alive; dropping it triggers the idempotent exit-path export (lifecycle::export_once). Combined with the panic hook, ctrlc handler, and optional atexit registered by lifecycle::install, this covers every realistic program-exit path.

§Module role

This is module 4 (the final module) of the auto-export feature. It ties modules 1-3 together into the user-facing API:

  • start / start_with initialize logging, install the global tracker, wire the lifecycle hooks, and optionally spawn a background flusher.
  • The returned MemScopeGuard owns the flusher handle and a clone of the tracker Arc. Its Drop impl joins the flusher (with a final flush) and then runs the idempotent exit-path export.

§Drop ordering

The flusher is dropped BEFORE the final export_once call so that the flusher’s shutdown-time final flush is visible to the export latch. The latch (lifecycle::EXPORTED) is set by whichever export runs first; the second is a no-op, so there is no double-write.

Structs§

MemScopeGuard
RAII handle that keeps the auto-export subsystem alive.

Functions§

start
Start memscope-rs with the default configuration.
start_with
Start memscope-rs with a custom configuration.