Expand description
A memory allocation wrapper that hits a callback when a threshold is reached:
use std::alloc;
use thresher::Thresher;
#[global_allocator]
// Wrap the standard system allocator
static THRESHER: Thresher<alloc::System> = Thresher::new(alloc::System);
fn main() {
// Set the threshold we care about reaching
THRESHER.set_threshold(100 * 1024 * 1024);
// Set the callback when the threshold is reached (note: may be called multiple times)
THRESHER.set_callback(|allocation| {
println!("Threshold reached! Allocated: {} bytes", allocation);
});
}Structsยง
- Thresher
- The main allocation wrapper.
Thresher::new()to wrap an existing allocator