Skip to main content

Module alloc

Module alloc 

Source
Expand description

A counting global allocator for memory measurements in tests and benchmarks.

ⓘ
#[global_allocator]
static A: simoom_sys::alloc::Counting = simoom_sys::alloc::Counting;

It forwards to the system allocator and keeps the net number of live heap bytes, in total and per thread (bytes freed on another thread than the one that allocated them count against the freeing thread).

Structs§

Counting
The counting allocator. See the module docs.

Functions§

allocation_calls
Allocation calls so far (allocations, and reallocations that grow), process-wide.
live_allocations
Heap allocations of the whole process not freed yet (when Counting is the global allocator).
release_free_memory
Asks the C allocator to give memory it holds free back to the operating system (glibc’s malloc_trim; elsewhere nothing). The event loops call it once after a burst, when they have been idle for a while (K2): glibc keeps what a thread freed in that thread’s arena, so a burst of large responses otherwise left tens of MB resident.
reset_thread_peak
Starts a new peak for thread_peak_bytes at the calling thread’s current thread_bytes.
thread_bytes
Net heap bytes allocated minus freed by the calling thread.
thread_peak_bytes
The highest thread_bytes of the calling thread since its last reset_thread_peak (or since it started): what a piece of code needs at its peak, scratch included.
total_bytes
Net live heap bytes of the whole process (when Counting is the global allocator).