peakmem_alloc

An instrumenting middleware for global allocators in Rust, useful to find the peak memory consumed by a function.

Example

```rust extern crate peakmem_alloc;

use peakmemalloc::{PeakAlloc, INSTRUMENTEDSYSTEM}; use std::alloc::System;

[global_allocator]

static GLOBAL: &PeakAlloc = &INSTRUMENTED_SYSTEM;

[test]

fn exampleusingregion() { GLOBAL.resetpeakmemory(); let x: Vec = Vec::withcapacity(1024); println!( "Peak Memory used by function : {:#?}", GLOBAL.getpeak_memory() ); }

```

Custom allocators

Currenty wrapping a custom allocator requires the use of the nightly compiler and compiling with the "nightly" feature due to the soon to stabilize use of the unstable const_fn_trait_bound and the fact that the internals of the instrumenting type are not public. If that's fine with you, a custom allocator can be wrapped as follows:

```rust

[global_allocator]

static GLOBAL: PeakAlloc = PeakAlloc::new(MyCustomAllocator::new()); ```