[#BloombergLP-bdlma-SequentialPool]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlma.adoc[bdlma]::SequentialPool
:relfileprefix: ../../
:mrdocs:

This class implements a fast memory pool that efficiently dispenses heterogeneous blocks of memory (of varying, user&hyphen;specified sizes) from a sequence of dynamically&hyphen;allocated internal buffers&period; Memory for the internal buffers is supplied by an (optional) allocator supplied at construction&semi; if no allocator is supplied, the currently installed default allocator is used&period; If an allocation exceeds the remaining free memory space in the current buffer, the pool replenishes its internal buffer with new memory to satisfy the request&period; This class is _exception_ _neutral_&colon; If memory cannot be allocated, the behavior is defined by the (optional) allocator specified at construction&period;

== Synopsis

Declared in `&lt;bdlma&lowbar;sequentialpool&period;h&gt;`

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

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlma/SequentialPool/2constructor-0251.adoc[`SequentialPool`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlma/SequentialPool/2destructor.adoc[`&#126;SequentialPool`] [.small]#[destructor]#
| Destroy this sequential pool&period; All memory allocated by this pool is released&period;
| xref:BloombergLP/bdlma/SequentialPool/allocate.adoc[`allocate`] 
| Return the address of a contiguous block of memory of the specified `size` (in bytes) according to the alignment strategy specified at construction&period; If `size` is 0, no memory is allocated and 0 is returned&period; If the allocation request exceeds the remaining free memory space in the current internal buffer, use the allocator supplied at construction to allocate a new internal buffer, then allocate memory from the new buffer&period;
| xref:BloombergLP/bdlma/SequentialPool/allocateAndExpand.adoc[`allocateAndExpand`] 
| Return the address of a contiguous block of memory of at least the specified `&ast;size` (in bytes), and load the actual amount of memory allocated in `&ast;size`&period; If `&ast;size` is 0, return 0 with no effect&period; If the allocation request exceeds the remaining free memory space in the current internal buffer, use the allocator supplied at construction to allocate a new internal buffer, then allocate memory from the new buffer&period;
| xref:BloombergLP/bdlma/SequentialPool/allocator.adoc[`allocator`] 
| Return the allocator used by this object to allocate memory&period; Note that this allocator can not be used to deallocate memory allocated through this pool&period;
| xref:BloombergLP/bdlma/SequentialPool/deleteObject.adoc[`deleteObject`] 
| Destroy the specified `object`&period; Note that this method has the same effect as the `deleteObjectRaw` method (since no deallocation is involved), and exists for consistency across pools&period;
| xref:BloombergLP/bdlma/SequentialPool/deleteObjectRaw.adoc[`deleteObjectRaw`] 
| Destroy the specified `object`&period; Note that memory associated with `object` is not deallocated because there is no `deallocate` method in `SequentialPool`&period;
| xref:BloombergLP/bdlma/SequentialPool/release.adoc[`release`] 
| Release all memory allocated through this pool and return to the underlying allocator _all_ memory&period; The pool is reset to its default&hyphen;constructed state, retaining the alignment and growth strategies, and the initial and maximum buffer sizes in effect following construction&period; The effect of subsequently &hyphen; to this invocation of `release` &hyphen; using a pointer obtained from this object prior to this call to `release` is undefined&period;
| xref:BloombergLP/bdlma/SequentialPool/reserveCapacity.adoc[`reserveCapacity`] 
| Reserve sufficient memory to satisfy allocation requests for at least the specified `numBytes` without replenishment (i&period;e&period;, without dynamic allocation)&period; If `numBytes` is 0, no memory is reserved&period; Note that, when the `numBytes` is distributed over multiple `allocate` requests &hyphen; due to alignment effects &hyphen; it is possible that not all `numBytes` of memory will be used for allocation before triggering dynamic allocation&period;
| xref:BloombergLP/bdlma/SequentialPool/rewind.adoc[`rewind`] 
| Release all memory allocated through this pool and return to the underlying allocator _only_ memory that was allocated outside of the typical internal buffer growth of this pool (i&period;e&period;, large blocks)&period; All retained memory will be used to satisfy subsequent allocations&period; The effect of subsequently &hyphen; to this invocation of `rewind` &hyphen; using a pointer obtained from this object prior to this call to `rewind` is undefined&period;
| xref:BloombergLP/bdlma/SequentialPool/truncate.adoc[`truncate`] 
| Reduce the amount of memory allocated at the specified `address` of the specified `originalSize` (in bytes) to the specified `newSize`&period; Return `newSize` after truncating, or `originalSize` if the memory block at `address` cannot be truncated&period; This method can only `truncate` the memory block returned by the most recent `allocate` request from this memory pool, and otherwise has no effect&period; The behavior is undefined unless the memory block at `address` was originally allocated by this memory pool, the size of the memory block at `address` is `originalSize`, `newSize &lt;&equals; originalSize`, and `release` was not called after allocating the memory block at `address`&period;
|===



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