Macaulay2 Engine
Loading...
Searching...
No Matches
myalloc.hpp File Reference

AllocLogger / StatsAllocator — single-threaded debug/benchmark instrumentation. More...

#include <iostream>

Go to the source code of this file.

Classes

class  AllocLogger
 Process-wide allocation counter used by StatsAllocator for debugging and benchmarking. More...
class  StatsAllocator< T >

Functions

std::ostream & operator<< (std::ostream &o, AllocLogger a)
template<class T1, class T2>
bool operator== (const StatsAllocator< T1 > &, const StatsAllocator< T2 > &) noexcept
template<class T1, class T2>
bool operator!= (const StatsAllocator< T1 > &, const StatsAllocator< T2 > &) noexcept

Detailed Description

AllocLogger / StatsAllocator — single-threaded debug/benchmark instrumentation.

Note
AI-generated documentation. Verify against the source before relying on it.

Declares AllocLogger with static counters (mNumAllocs, mAllocSize, mNumDeallocs, mCurrentAllocSize, mHighWater) and the StatsAllocator wrapper that bumps those counters on every allocation / deallocation. The class is intentionally minimal: counters are static so per-type statistics share a collector, and there is no locking on the counter increments (the in-source comment is explicit: "not thread safe"). StatsAllocator::allocate / deallocate log the size, then call straight through to ::operator new / ::operator delete; there is no free-skipping debug mode. It is for debugging and benchmarking only — not safe in any path the supervisor parallelises.

Production allocations route through newdelete.hpp's our_new_delete (Boehm GC). The legacy mem.hpp size-class stash allocator is now stubbed (its new_elem / delete_elem short-circuit to newarray_clear / freemem), so AllocLogger is the only opt-in counter source left — reach for it when you want to count allocations of a single type in a benchmark run and dump the totals afterward.

See also
newdelete.hpp
mem.hpp

Definition in file myalloc.hpp.