Allocator that manages pools of memory blocks of varying sizes.

Synopsis

Declared in <bdlma_multipoolallocator.h>

class MultipoolAllocator
    : public 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

Name

Description

ManagedAllocator

Protocol for allocators that support releasing all allocated memory.

Type Aliases

Name

Description

size_type

Alias for an unsigned integral type capable of representing the number of bytes in this platform's virtual address space.

Member Functions

Name

Description

MultipoolAllocator [constructor]

Constructors

~MultipoolAllocator [destructor] [virtual]

Destroy this multipool allocator. All memory allocated from this allocator is released.

operator=

allocate

allocate overloads

deallocate

Return a memory block to this allocator for reuse.

deleteObject

deleteObject overloads

deleteObjectRaw

deleteObjectRaw overloads

is_equal

maxPooledBlockSize

Return the maximum size of memory blocks pooled by this allocator.

numPools

Return the number of pools managed by this multipool allocator.

release [virtual]

Release all memory currently allocated through this multipool allocator.

reserveCapacity

Reserve capacity for at least numObjects objects of size bytes.

Static Member Functions

Name

Description

throwBadAlloc

Throw std::bad_alloc or abort the program.

Protected Member Functions

Name

Description

do_allocate [virtual]

Return a newly allocated block of at least bytes with alignment.

do_deallocate [virtual]

Return the memory block at p having bytes and alignment.

do_is_equal [virtual]

Return whether this allocator can exchange memory with other.

Created with MrDocs