Crate peakmem_alloc
source ·Expand description
An instrumenting middleware for global allocators in Rust, useful in testing for validating assumptions regarding allocation patterns, and potentially in production loads to monitor for memory leaks.
Example
extern crate peakmem_alloc;
use peakmem_alloc::{PeakAlloc, INSTRUMENTED_SYSTEM};
use std::alloc::System;
#[global_allocator]
static GLOBAL: &PeakAlloc<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.