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 dhat::Alloc as the 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 dhat directly.

§Example

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

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