Skip to main content

Module dhat

Module dhat 

Source
Expand description

Exact DHAT v2 heap/lifetime profiling controls.

DHAT records every non-internal allocation from the moment start succeeds. It is intended for short diagnostic runs and tests rather than continuous production telemetry. The generated JSON opens in the standard Valgrind dh_view.html viewer. It is independent of sampled prof profiling and of mi_memory_set_callbacks.

Requires the opt-in dhat cargo feature (C MI_DHAT=1; off by default, enable it with features = ["dhat"]). Without it the observer is compiled out of the allocator, the API stays present for source compatibility, and start returns false, is_enabled and Stats::enabled are false, and dump_file returns an error.

Structs§

Stats
Snapshot of exact DHAT collector state.

Functions§

dump_file
Serialize the current or stopped measurement window as a DHAT v2 JSON file.
is_enabled
Whether exact DHAT tracking is currently active.
start
Start exact allocation/lifetime tracking. Returns false if it is already active, or if the crate was built without the dhat feature.
stats
Read the collector’s exact counters. Returns a zero/default snapshot only if the linked C library rejected the versioned ABI structure, or if the crate was built without the dhat feature.
stop
Stop observing allocation events. Retained records remain available to dump_file so a caller can stop a measurement window before serializing its report.