Skip to content

tenzr::MemoryPool

Process-wide cache of reusable PinnedBuffer allocations, keyed by size.

#include <memory_pool.h>

Public Functions

Name
MemoryPool & Instance()
The process-wide singleton pool.
MemoryPool()
Mark the pool alive so buffers may safely return to it during teardown.
~MemoryPool()
Mark the pool dead and release all cached free buffers.
MemoryPool(const MemoryPool & ) =delete
MemoryPool & operator=(const MemoryPool & ) =delete
std::shared_ptr< PinnedBuffer > Allocate(size_t size_bytes, bool page_locked =true)
Return a buffer of at least size_bytes, reusing a cached one when possible.
void Clear()
Release all cached free buffers.

Public Functions Documentation

function Instance

static MemoryPool & Instance()

The process-wide singleton pool.

Return: Reference to the singleton MemoryPool.

Get the process-wide pinned-buffer pool.

function MemoryPool

MemoryPool()

Mark the pool alive so buffers may safely return to it during teardown.

function ~MemoryPool

~MemoryPool()

Mark the pool dead and release all cached free buffers.

function MemoryPool

MemoryPool(
    const MemoryPool & 
) =delete

function operator=

MemoryPool & operator=(
    const MemoryPool & 
) =delete

function Allocate

std::shared_ptr< PinnedBuffer > Allocate(
    size_t size_bytes,
    bool page_locked =true
)

Return a buffer of at least size_bytes, reusing a cached one when possible.

Parameters:

  • size_bytes Requested capacity in bytes.
  • page_locked Whether a freshly allocated buffer is page-locked.

Return: A buffer that returns itself to the pool on destruction.

Obtain a buffer of size_bytes, reusing a same-sized free buffer when available.

function Clear

void Clear()

Release all cached free buffers.

Discard every cached free buffer.