Crate peakmem_alloc
source ·Expand description
An instrumenting allocator wrapper to compute (scoped) peak memory consumption.
§Example
use peakmem_alloc::*;
use std::alloc::System;
#[global_allocator]
static GLOBAL: &PeakMemAlloc<System> = &INSTRUMENTED_SYSTEM;
fn main() {
GLOBAL.reset_peak_memory();
let _x: Vec<u8> = Vec::with_capacity(1_024);
println!(
"Peak Memory used by function : {:#?}",
GLOBAL.get_peak_memory()
);
}
Structs§
- An allocator middleware which keeps track of peak memory consumption.
Statics§
- An instrumented instance of the system allocator.
Traits§
- The PeakAllocTrait trait provides a common interface for all allocators.