Skip to main content

Module counting

Module counting 

Source
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_live at the end of a scope).

Structs§

AllocStats
A snapshot of allocation statistics produced by CountingAllocator::stats.
CountingAllocator
An Allocator wrapper that records allocation and deallocation statistics.