folly::Arena

Arena that allocates memory in blocks and frees it all at destruction.

Synopsis

Declared in <folly/memory/Arena.h>

template<class Alloc>
class Arena;

Description

Memory obtained from allocate() stays alive until the arena is cleared or destroyed; individual deallocations are no-ops. Blocks come from the user-supplied allocator Alloc.

Member Functions

NameDescription
Arena [constructor]Constructors
~Arena [destructor]Destroys the arena, freeing every block it owns.
operator= Assignment operators
allocate Allocates a properly aligned chunk of memory from the arena.
bytesUsed Gets the total number of "used" bytes.
clear Resets the arena, reusing regular blocks and freeing large ones.
deallocate Releases memory back to the arena; this is intentionally a no-op.
merge Transfers ownership of all memory allocated from other to this arena.
totalSize Gets the total memory used by the arena.

Static Data Members

NameDescription
kBlockOverhead Per-block bookkeeping overhead, in bytes.
kDefaultMaxAlign Default maximum alignment, in bytes, honored by allocations.
kDefaultMinBlockSize Default minimum size, in bytes, of each regular block.
kNoSizeLimit Sentinel value meaning the arena has no total size limit.

Derived Classes

NameDescription
SysArena Arena that uses the system allocator (malloc / free)