[#LockedPool]
= LockedPool
:mrdocs:

Pool for locked memory chunks&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class LockedPool;
----

== Description

To avoid sensitive key data from being swapped to disk, the memory in this pool is locked&sol;pinned&period;

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

Unlike a normal C heap, the administrative structures are separate from the managed memory&period; This has been done as the sizes and bases of objects are not in themselves sensitive information, as to conserve precious locked memory&period; In some operating systems the amount of memory that can be locked is small&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/2constructor-09.adoc[`LockedPool`]         [.small]#[constructor]#
| Constructors
| xref:LockedPool/2destructor.adoc[`&#126;LockedPool`] [.small]#[destructor]#
| Destroys the pool and releases its arenas&period;
| 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 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;
|===


== Derived Classes

[cols="1,4"]
|===
| Name| Description
| xref:LockedPoolManager.adoc[`LockedPoolManager`] 
| Singleton class to keep track of locked (ie, non&hyphen;swappable) memory, for use in std&colon;&colon;allocator templates&period;
|===


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