Expand description
Instrumented allocator wrapper for diagnostics and testing.
CountingAllocator wraps any Allocator and records per-call
statistics: number of allocations / deallocations and total bytes involved.
It is transparent — every call is forwarded unchanged to the inner
allocator — and adds negligible overhead (four Cell<usize> increments).
§Typical Use Cases
- Unit tests — assert that a data structure performs exactly the expected number of allocations.
- Benchmarks — measure live byte footprint.
- Debug builds — detect memory leaks (non-zero
bytes_liveat the end of a scope).
Structs§
- Alloc
Stats - A snapshot of allocation statistics produced by
CountingAllocator::stats. - Counting
Allocator - An
Allocatorwrapper that records allocation and deallocation statistics.