This class defines a concrete "test" allocator mechanism that implements the bdlma::ManagedAllocator protocol.
Declared in <balst_stacktracetestallocator.h>
class StackTraceTestAllocator
: public bdlma::ManagedAllocator
Provides instrumentation to track the set of all blocks allocated by this allocator that have yet to be freed. At any time it can produce a report about such blocks, listing for each place that any unfreed blocks were allocated * the number of unfreed blocks allocated at that place * the stack trace at that place The allocator will also detect redundant frees of the same block, and frees by the wrong allocator. The client can choose whether such violations are handled by a core dump, or merely a report being written.
Note that, unlike many other allocators, this allocator does DOES NOT rely on the currently installed default allocator (see bslma_default) at all, but instead -- by default -- uses MallocFreeAllocator singleton, which in turn calls the C Standard Library functions malloc and free as needed. Clients may, however, override this allocator by supplying (at construction) any other allocator implementing the bslma::Allocator protocol.
| Name | Description |
|---|---|
bdlma::ManagedAllocator | Protocol for allocators that support releasing all allocated memory. |
| Name | Description |
|---|---|
FailureHandler | Type of functor called by this object to handle allocation failures. |
size_type | Alias for an unsigned integral type capable of representing the number of bytes in this platform's virtual address space. |
| Name | Description |
|---|---|
StackTraceTestAllocator [constructor] | Constructors |
~StackTraceTestAllocator [destructor] [virtual] | Destroy this allocator. |
operator= | |
allocate | Return a newly allocated block of memory of the specified positive size (in bytes). |
allocationLimit | Return the current number of allocation requests left before an exception is thrown. A negative value indicates that no exception is scheduled. |
deallocate | Return the memory block at the specified address back to this allocator. |
deleteObject | deleteObject overloads |
deleteObjectRaw | deleteObjectRaw overloads |
failureHandler | Return a reference to the function that will be called when a failure is observed. |
is_equal | |
numAllocations | Return the number of allocations from this object that have occurred since creation. |
numBlocksInUse | Return the number of blocks currently allocated from this object. |
release [virtual] | Deallocate all memory held by this allocator. |
reportBlocksInUse | Write a report of currently allocated blocks to ostream. |
setAllocationLimit | Set the allocation-limit before an exception is thrown. |
setDemanglingPreferredFlag | Set whether demangling of symbols is preferred in diagnostics. |
setFailureHandler | Set the failure handler associated with this allocator to func. |
setName | Set the name of this allocator to the specified name. |
setOstream | Set the stream to which diagnostics will be written to the specified ostream. If setOstream is never called, diagnostics will be written to bsl::cerr. |
| Name | Description |
|---|---|
failAbort | Call bsl::abort() to terminate the process on failure. |
failNoop | Do nothing when invoked as a failure handler. |
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. |