#memory-allocator #global-allocator #memory

accounting-allocator

A global memory allocator wrapper which counts allocated and deallocated bytes

2 unstable releases

0.2.0 Dec 13, 2022
0.1.0 Nov 28, 2022

#688 in Memory management

Download history 4/week @ 2025-12-07 15/week @ 2025-12-14 24/week @ 2026-01-04 58/week @ 2026-01-11 12/week @ 2026-01-18 28/week @ 2026-01-25 46/week @ 2026-02-01 36/week @ 2026-02-08 5/week @ 2026-02-15 4/week @ 2026-02-22 30/week @ 2026-03-01 42/week @ 2026-03-08 45/week @ 2026-03-15 26/week @ 2026-03-22

143 downloads per month

MIT license

22KB
369 lines

accounting-allocator is a global memory allocator wrapper which counts allocated and deallocated bytes.

Usage

use accounting_allocator::{AccountingAlloc, AllTimeAllocStats};

#[global_allocator]
static GLOBAL_ALLOCATOR: AccountingAlloc = AccountingAlloc::new();

fn main() {
    let AllTimeAllocStats { alloc, dealloc, largest_alloc } = GLOBAL_ALLOCATOR.count().all_time;
    println!("alloc {alloc} dealloc {dealloc} largest_alloc {largest_alloc}");
}

accounting-allocator

A Rust global memory allocator wrapper which counts allocated and deallocated bytes, avoiding contention between threads.

The accounting allocator avoids contention by using per-thread atomic counters. It incurs small one-time global and per-thread initialization overhead.

API Documentation
Private Documentation

Contributing Bug Reports

GitHub is the project's bug tracker. Please search for similar existing issues before submitting a new one.

License

Licensed under MIT.

Dependencies

~380KB