[#LockedPoolManager]
= LockedPoolManager
:mrdocs:

Singleton class to keep track of locked (ie, non&hyphen;swappable) memory, for use in std&colon;&colon;allocator templates&period;

== Synopsis

Declared in `&lt;support&sol;lockedpool&period;h&gt;`

[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&period;e&period;, see MSVC&apos;s vector&lt;T&gt; implementation where it allocates 1 byte of memory in the allocator&period;) Due to the unpredictable order of static initializers, we have to make sure the LockedPoolManager instance exists before any other STL&hyphen;based objects that use secure&lowbar;allocator are created&period; So instead of having LockedPoolManager also be static&hyphen;initialized, it is created on demand&period;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:LockedPool.adoc[LockedPool]`
| Pool for locked memory chunks&period;
|===

== Types

[cols="1,4"]
|===
| Name| Description
| xref:LockedPool/Stats-0c.adoc[`Stats`] 
| Memory statistics&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:LockedPool/LockingFailed_Callback.adoc[`LockingFailed&lowbar;Callback`] 
| Callback when allocation succeeds but locking fails&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:LockedPool/operator_assign.adoc[`operator&equals;`]  [.small]#[deleted]#
| Deleted copy assignment&semi; a LockedPool cannot be copied&period;
| xref:LockedPool/alloc.adoc[`alloc`] 
| Allocate size bytes from this arena&period; Returns pointer on success, or 0 if memory is full or the application tried to allocate 0 bytes&period;
| xref:LockedPool/free.adoc[`free`] 
| Free a previously allocated chunk of memory&period; Freeing the zero pointer has no effect&period; Raises std&colon;&colon;runtime&lowbar;error in case of error&period;
| 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&lowbar;ALIGN`] 
| Chunk alignment&period; Another compromise&period; Setting this too high will waste memory, setting it too low will facilitate fragmentation&period;
| xref:LockedPool/ARENA_SIZE.adoc[`ARENA&lowbar;SIZE`] 
| Size of one arena of locked memory&period; This is a compromise&period; Do not set this too low, as managing many arenas will increase allocation and deallocation overhead&period; Setting it too high allocates more locked memory from the OS than strictly necessary&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
