BDE 4.14.0 Production release
|
Typedefs | |
typedef bslma::InfrequentDeleteBlockList | bslma_InfrequentDeleteBlockList |
This alias is defined for backward compatibility. | |
Provide allocation and management of a sequence of memory blocks.
This component implements a memory manager that allocates and manages a sequence of memory blocks, each potentially of a different size as specified in the allocate
method's invocation. The bslma::InfrequentDeleteBlockList
object's release
method deallocates the entire sequence of memory blocks, as does its destructor.
This component does not allow individual items to be deallocated.
The bslma::InfrequentDeleteBlockList
object is commonly used to supply memory to more elaborate memory managers that distribute parts of a memory block supplied by the bslma::InfrequentDeleteBlockList
object. The my_StrPool
memory pool manager shown below requests relatively large blocks of memory from its bslma::InfrequentDeleteBlockList
member object and distributes memory chunks of varying sizes from each block on demand:
In the code above, the my_StrPool
memory manager allocates from its bslma::InfrequentDeleteBlockList
member object an initial memory block of size INITIAL_SIZE
. This size is multiplied by GROW_FACTOR
each time a deplete memory block is replaced by a newly allocated block. The allocate
method distributes memory from the current memory block piecemeal, except when the requested size: 1) is not available in the current block and 2) exceeds the THRESHOLD_SIZE
, in which case a separate memory block is allocated and returned. When the my_StrPool
memory manager is destroyed, its bslma::InfrequentDeleteBlockList
member object is also destroyed, which in turn automatically deallocates all of its managed memory blocks.