A bad memory "profiler" for production.
UseCase
enum.Alloc::with_usecase
.```rust use num_enum::{TryFromPrimitive, IntoPrimitive};
enum MyUseCase { #[default] None, LoadConfig, ProcessData, }
impl memoria::UseCase for MyUseCase {}
static ALLOCATOR: memoria::Alloc
fn loadconfig() { let _guard = ALLOCATOR.withusecase(MyUseCase::LoadConfig); println!("loading config..."); // consume some memory let _temporary = vec![0u8; 256]; }
fn processdata() { let _guard = ALLOCATOR.withusecase(MyUseCase::ProcessData); // consume some more memory let _temporary = vec![0u8; 2048]; }
fn main() { loadconfig(); processdata();
println!("memory usage stats:");
ALLOCATOR.with_recorder(|recorder| {
recorder.flush(
|usecase, stat| {
println!("{usecase:?}: {stat:?}");
},
|err, count| {
println!("{err:?}: {count}");
}
);
Ok(())
}).ok();
} ```
Licensed under the MIT license, see ./LICENSE
.