|
Macaulay2 Engine
|
Bump-pointer arena allocator for transient inner-loop allocations. More...
#include <memtailor/Arena.h>#include <iostream>#include <utility>Go to the source code of this file.
Classes | |
| class | MemoryBlock |
| Thin RAII wrapper around memtailor::Arena providing bump-pointer array allocation with optional mutex protection. More... | |
Bump-pointer arena allocator for transient inner-loop allocations.
MemoryBlock is a thin wrapper around memt::Arena from the memtailor submodule. allocateArray<T>(nelems) returns the next nelems * sizeof(T) bytes as a (begin, end) pair; safeAllocateArray<T, MutexType> does the same under a caller-supplied scoped lock for shared-arena hot paths. Only the top of the stack can be released: freeTopArray(begin, end) unwinds the most-recent allocation, and shrinkLastAllocate composes free-and-re-alloc to resize it. deallocateAll() releases everything without destroying the MemoryBlock; the destructor releases the underlying memt::Arena*. This matches the "millions of tiny objects allocated during one GB step, then all thrown away" shape of the engine's hot paths in f4/, gb-f4/, schreyer-resolution/, and NCAlgebras/.
Memory comes from the system heap, not bdwgc, so anything stored inside a MemoryBlock must be plain-old-data — the garbage collector will not scan these pages. The underlying allocArrayNoCon also skips per-element constructor calls; callers either initialise the bytes explicitly or treat them as raw storage (encoded monomials, exponent vectors, S-pair records).
Definition in file MemoryBlock.hpp.