Concrete allocator that counts bytes currently in use and ever allocated.
This class defines a concrete "counting" allocator mechanism that implements the bslma::Allocator protocol, and provides instrumentation to track: (1) the number of bytes currently in use, and (2) the cumulative number of bytes that have ever been allocated. The accumulated statistics are based solely on the number of bytes requested (see allocate).
Note that, like many other allocators, this allocator relies on the currently installed default allocator (see bslma_default). Clients may, however, override this allocator by supplying (at construction) any other allocator implementing the bslma::Allocator protocol provided that it is fully thread-safe.
| Name | Description |
|---|---|
bslma::Allocator | Pure abstract protocol for clients and suppliers of raw memory. |
| Name | Description |
|---|---|
size_type | Alias for an unsigned integral type capable of representing the number of bytes in this platform's virtual address space. |
| Name | Description |
|---|---|
CountingAllocator [constructor] | Constructors |
~CountingAllocator [destructor] [virtual] | Destroy this allocator object. Note that destroying this allocator has no effect on any outstanding allocated memory. |
operator= | |
allocate | allocate overloads |
deallocate | Return the memory block at the specified address back to this allocator. |
deleteObject | deleteObject overloads |
deleteObjectRaw | deleteObjectRaw overloads |
is_equal | |
name | Return the name of this counting allocator, or 0 if no name was specified at construction. |
numBytesInUse | Return the number of bytes currently allocated from this object. Note that numBytesInUse() <= numBytesTotal(). |
numBytesTotal | Return the cumulative number of bytes ever allocated from this object. Note that numBytesInUse() <= numBytesTotal(). |
print | Write the accumulated state information held in this allocator to the specified stream in some reasonable (multi-line) format, and return a reference to stream. |
| Name | Description |
|---|---|
throwBadAlloc | Throw std::bad_alloc or abort the program. |
| 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. |