[#BloombergLP-bdlma-MultipoolAllocator] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlma.adoc[bdlma]::MultipoolAllocator :relfileprefix: ../../ :mrdocs: Allocator that manages pools of memory blocks of varying sizes. == Synopsis Declared in `<bdlma_multipoolallocator.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class MultipoolAllocator : public xref:BloombergLP/bdlma/ManagedAllocator.adoc[ManagedAllocator] ---- == Description This class implements the `bdlma::ManagedAllocator` protocol to provide an allocator that maintains a configurable number of `bdlma::Pool` objects, each dispensing memory blocks of a unique size. The `bdlma::Pool` objects are placed in an array, with each successive pool managing memory blocks of size twice that of the previous pool. Each multipool allocation (deallocation) request allocates memory from (returns memory to) the internal pool having the smallest block size not less than the requested size, or, if no pool manages memory blocks of sufficient sized, from a separately managed list of memory blocks. Both the `release` method and the destructor of a `bdlma::MultipoolAllocator` release all memory currently allocated via the object. == Base Classes [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlma/ManagedAllocator.adoc[ManagedAllocator]` | Protocol for allocators that support releasing all allocated memory. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/size_type.adoc[`size_type`] | Alias for an unsigned integral type capable of representing the number of bytes in this platform's virtual address space. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlma/MultipoolAllocator/2constructor-0a7.adoc[`MultipoolAllocator`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlma/MultipoolAllocator/2destructor.adoc[`~MultipoolAllocator`] [.small]#[destructor]# [.small]#[virtual]# | Destroy this multipool allocator. All memory allocated from this allocator is released. | xref:BloombergLP/bslma/Allocator/operator_assign.adoc[`operator=`] | | xref:BloombergLP/bdlma/MultipoolAllocator/allocate-01.adoc[`allocate`] | `allocate` overloads | xref:BloombergLP/bdlma/MultipoolAllocator/deallocate-08.adoc[`deallocate`] | Return a memory block to this allocator for reuse. | xref:BloombergLP/bslma/Allocator/deleteObject-09.adoc[`deleteObject`] | `deleteObject` overloads | xref:BloombergLP/bslma/Allocator/deleteObjectRaw-06f.adoc[`deleteObjectRaw`] | `deleteObjectRaw` overloads | xref:BloombergLP/bslma/Allocator/is_equal.adoc[`is_equal`] | | xref:BloombergLP/bdlma/MultipoolAllocator/maxPooledBlockSize.adoc[`maxPooledBlockSize`] | Return the maximum size of memory blocks pooled by this allocator. | xref:BloombergLP/bdlma/MultipoolAllocator/numPools.adoc[`numPools`] | Return the number of pools managed by this multipool allocator. | xref:BloombergLP/bdlma/MultipoolAllocator/release.adoc[`release`] [.small]#[virtual]# | Release all memory currently allocated through this multipool allocator. | xref:BloombergLP/bdlma/MultipoolAllocator/reserveCapacity.adoc[`reserveCapacity`] | Reserve capacity for at least `numObjects` objects of `size` bytes. |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/throwBadAlloc.adoc[`throwBadAlloc`] | Throw `std::bad_alloc` or abort the program. |=== == Protected Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/Allocator/do_allocate.adoc[`do_allocate`] [.small]#[virtual]# | Return a newly allocated block of at least `bytes` with `alignment`. | xref:BloombergLP/bslma/Allocator/do_deallocate.adoc[`do_deallocate`] [.small]#[virtual]# | Return the memory block at `p` having `bytes` and `alignment`. | xref:BloombergLP/bslma/Allocator/do_is_equal.adoc[`do_is_equal`] [.small]#[virtual]# | Return whether this allocator can exchange memory with `other`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#