#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

#684 in Memory management

Download history 75/week @ 2024-07-22 30/week @ 2024-07-29 24/week @ 2024-08-05 13/week @ 2024-08-12 42/week @ 2024-08-19 40/week @ 2024-08-26 49/week @ 2024-09-02 1/week @ 2024-09-16 130/week @ 2024-09-23 42/week @ 2024-09-30 28/week @ 2024-10-07 18/week @ 2024-10-14 6/week @ 2024-10-21 25/week @ 2024-10-28 67/week @ 2024-11-04

117 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