This class defines a concrete "test" allocator mechanism that implements the bdlma::ManagedAllocator protocol, and 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.
Synopsis
Declared in <balst_stacktracetestallocator.h>
class StackTraceTestAllocator
: public bdlma::ManagedAllocator
Description
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.
Base Classes
Name |
Description |
This protocol class extends |
Type Aliases
Name |
Description |
Type of functor called by this object to handle allocation failures. Note that this can be set and accessed using the |
|
Alias for an unsigned integral type capable of representing the number of bytes in this platform's virtual address space. |
Member Functions
Name |
Description |
|
Constructors |
|
Destroy this allocator. Report any memory leaks to the |
Return a newly allocated block of memory of the specified positive |
|
Return the current number of allocation requests left before an exception is thrown. A negative value indicates that no exception is scheduled. |
|
Return the memory block at the specified |
|
|
|
|
|
Return a reference to the function that will be called when a failure is observed. |
|
Return the number of allocations from this object that have occurred since creation. Note that this does not count allocations of 0 length, which return null pointers. |
|
Return the number of blocks currently allocated from this object. |
|
|
Deallocate all memory held by this allocator. |
Write a report to the specified |
|
Set the number of valid allocation requests before an exception is to be thrown for this allocator to the specified |
|
Set the |
|
Set the failure handler associated with this allocator object to the specified |
|
Set the name of this allocator to the specified |
|
Set the stream to which diagnostics will be written to the specified |
Static Member Functions
Name |
Description |
Calls |
|
Does nothing. |
|
Throw |
Protected Member Functions
Name |
Description |
|
Return a newly allocated block of memory of (at least) the specified positive |
|
Return the memory block at the specified |
|
Return |
Created with MrDocs