Skip to main content

install_global_allocator

Macro install_global_allocator 

Source
macro_rules! install_global_allocator {
    () => { ... };
}
Available on crate feature alloc-tracking only.
Expand description

Install the allocation-tracking global allocator.

Available with the alloc-tracking feature. Invoke at module scope in your binary or test target — the macro expands to a #[global_allocator] static declaration that consumers cannot otherwise express without depending on mod-alloc directly.

The backend is mod-alloc’s dhat_compat::Alloc (drop-in for dhat-rs’s dhat::Alloc); behaviour, API surface, and JSON output remain DHAT-viewer-compatible.

§Example

// in main.rs or a test target's top level:
dev_bench::install_global_allocator!();

// Optionally pull the same compat surface into your own code:
use mod_alloc::dhat_compat as dhat;

fn main() {
    let _profiler = dhat::Profiler::new_heap();
    // ... benchmarked code ...
}