#memory-allocator #allocator #memory #global-allocator #count #byte #accounting

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

#657 in Memory management

Download history 14/week @ 2024-03-13 152/week @ 2024-03-20 47/week @ 2024-03-27 54/week @ 2024-04-03 32/week @ 2024-04-10 23/week @ 2024-04-17 25/week @ 2024-04-24 1/week @ 2024-05-01 4/week @ 2024-05-08 14/week @ 2024-05-15 36/week @ 2024-05-22 45/week @ 2024-05-29 21/week @ 2024-06-05 11/week @ 2024-06-12 11/week @ 2024-06-19 8/week @ 2024-06-26

57 downloads per month

MIT license

22KB
369 lines

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.


lib.rs:

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}");
}

Dependencies

~395KB