Singleton class to keep track of locked (ie, non‐swappable) memory, for use in std::allocator templates.
Synopsis
Declared in <support/lockedpool.h>
class LockedPoolManager
: public LockedPool
Description
Some implementations of the STL allocate memory in some constructors (i.e., see MSVC's vector<T> implementation where it allocates 1 byte of memory in the allocator.) Due to the unpredictable order of static initializers, we have to make sure the LockedPoolManager instance exists before any other STL‐based objects that use secure_allocator are created. So instead of having LockedPoolManager also be static‐initialized, it is created on demand.
Base Classes
Name |
Description |
Pool for locked memory chunks. |
Types
Name |
Description |
Memory statistics. |
Type Aliases
Name |
Description |
Callback when allocation succeeds but locking fails. |
Member Functions
Name |
Description |
|
Deleted copy assignment; a LockedPool cannot be copied. |
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 a previously allocated chunk of memory. Freeing the zero pointer has no effect. Raises std::runtime_error in case of error. |
|
Get pool usage statistics |
Static Member Functions
Name |
Description |
Return the current instance, or create it once |
Static Data Members
Name |
Description |
Chunk alignment. Another compromise. Setting this too high will waste memory, setting it too low will facilitate fragmentation. |
|
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. |
Created with MrDocs