[#LockedPoolManager] = LockedPoolManager :mrdocs: Singleton class to keep track of locked (ie, non‐swappable) memory, for use in std::allocator templates. == Synopsis Declared in `<support/lockedpool.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class LockedPoolManager : public xref:LockedPool.adoc[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 [cols="1,4"] |=== | Name| Description | `xref:LockedPool.adoc[LockedPool]` | Pool for locked memory chunks. |=== == Types [cols="1,4"] |=== | Name| Description | xref:LockedPool/Stats-0c.adoc[`Stats`] | Memory statistics. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:LockedPool/LockingFailed_Callback.adoc[`LockingFailed_Callback`] | Callback when allocation succeeds but locking fails. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:LockedPool/operator_assign.adoc[`operator=`] [.small]#[deleted]# | Deleted copy assignment; a LockedPool cannot be copied. | xref:LockedPool/alloc.adoc[`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. | xref:LockedPool/free.adoc[`free`] | Free a previously allocated chunk of memory. Freeing the zero pointer has no effect. Raises std::runtime_error in case of error. | xref:LockedPool/stats-0a.adoc[`stats`] | Get pool usage statistics |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:LockedPoolManager/Instance.adoc[`Instance`] | Return the current instance, or create it once |=== == Static Data Members [cols="1,4"] |=== | Name| Description | xref:LockedPool/ARENA_ALIGN.adoc[`ARENA_ALIGN`] | Chunk alignment. Another compromise. Setting this too high will waste memory, setting it too low will facilitate fragmentation. | xref:LockedPool/ARENA_SIZE.adoc[`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. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#