Pool for locked memory chunks.

Synopsis

Declared in <support/lockedpool.h>

class LockedPool;

Description

To avoid sensitive key data from being swapped to disk, the memory in this pool is locked/pinned.

An arena manages a contiguous region of memory. The pool starts out with one arena but can grow to multiple arenas if the need arises.

Unlike a normal C heap, the administrative structures are separate from the managed memory. This has been done as the sizes and bases of objects are not in themselves sensitive information, as to conserve precious locked memory. In some operating systems the amount of memory that can be locked is small.

Types

Name

Description

Stats

Memory statistics.

Type Aliases

Name

Description

LockingFailed_Callback

Callback when allocation succeeds but locking fails.

Member Functions

Name

Description

LockedPool [constructor]

Constructors

~LockedPool [destructor]

Destroys the pool and releases its arenas.

operator= [deleted]

Deleted copy assignment; a LockedPool cannot be copied.

alloc

Allocate size bytes from this arena. Returns pointer on success, or 0 if memory is full or the application tried to allocate 0 bytes.

free

Free a previously allocated chunk of memory. Freeing the zero pointer has no effect. Raises std::runtime_error in case of error.

stats

Get pool usage statistics

Static Data Members

Name

Description

ARENA_ALIGN

Chunk alignment. Another compromise. Setting this too high will waste memory, setting it too low will facilitate fragmentation.

ARENA_SIZE

Size of one arena of locked memory. This is a compromise. Do not set this too low, as managing many arenas will increase allocation and deallocation overhead. Setting it too high allocates more locked memory from the OS than strictly necessary.

Derived Classes

Name

Description

LockedPoolManager

Singleton class to keep track of locked (ie, non‐swappable) memory, for use in std::allocator templates.

Created with MrDocs