Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
|
Logging implementation used by Allocator (see below). More...
#include <Teuchos_Details_Allocator.hpp>
Public Types | |
typedef std::size_t | size_type |
Type of the size of an allocation or deallocation. More... | |
Static Public Member Functions | |
static void | logAllocation (std::ostream &out, const size_type numEntries, const size_type numBytes, const char typeName[], const bool verbose) |
Log an allocation. More... | |
static void | logDeallocation (std::ostream &out, const size_type numEntries, const size_type numBytes, const char typeName[], const bool verbose) |
Log a deallocation, that was previously logged using logAllocation(). More... | |
static size_type | curAllocInBytes () |
Current total allocation in bytes. More... | |
static size_type | maxAllocInBytes () |
Max total allocation ("high water mark") in bytes. More... | |
static void | resetAllocationCounts () |
Reset the current and max total allocation numbers to zero. More... | |
Static Private Attributes | |
static size_type | curAllocInBytes_ = 0 |
Current total allocation in bytes. More... | |
static size_type | maxAllocInBytes_ = 0 |
Max total allocation ("high water mark") in bytes. More... | |
Logging implementation used by Allocator (see below).
Please refer to teuchos/core/test/HashTable/Allocator_atexit.cpp
for an example of how to register an atexit() hook that reports current and maximum memory usage at exit from main(). It would be easy to adapt this example to register an MPI_Finalize() hook, using the MPI standard idiom of attaching an attribute to MPI_COMM_SELF.
Definition at line 43 of file Teuchos_Details_Allocator.hpp.
typedef std::size_t Teuchos::Details::AllocationLogger::size_type |
Type of the size of an allocation or deallocation.
This must match Allocator::size_type (see below).
Definition at line 48 of file Teuchos_Details_Allocator.hpp.
|
static |
Log an allocation.
This is useful for Allocator<T>, but not so useful for users, unless they are writing a custom Allocator and want it use this class for logging.
out | [out] Output stream to which to write logging information, if verbose is true. |
numEntries | [in] Number of entries (of type T ) in the allocated array (1 if just allocating one instance of T ). |
numBytes | [in] Number of bytes in the allocated array. This would normally be numEntries*sizeof(T) , at least for types T which are "plain old data" (POD) or structs thereof. We make you compute this, so that the logger doesn't have to know about (e.g., be templated on) the type T . |
typeName | [in] Human-readable name of the type T , for which you are logging an allocation. |
verbose | [in] Whether to print logging information to the given output stream out . |
Definition at line 18 of file Teuchos_Details_Allocator.cpp.
|
static |
Log a deallocation, that was previously logged using logAllocation().
This is useful for Allocator<T>, but not so useful for users, unless they are writing a custom Allocator and want it use this class for logging.
out | [out] Output stream to which to write logging information, if verbose is true. |
numEntries | [in] Number of entries (of type T ) in the deallocated array (1 if just allocating one instance of T ). Note that the allocate() function in the C++ Standard Library's Allocator concept gets this information, unlike free() or operator delete[] . |
numBytes | [in] Number of bytes in the deallocated array. This would normally be numEntries*sizeof(T) , at least for types T which are "plain old data" (POD) or structs thereof. We make you compute this, so that the logger doesn't have to know about (e.g., be templated on) the type T . |
typeName | [in] Human-readable name of the type T , for which you are logging a deallocation. |
verbose | [in] Whether to print logging information to the given output stream out . |
Definition at line 38 of file Teuchos_Details_Allocator.cpp.
|
static |
Current total allocation in bytes.
This count includes allocations using Allocator<T> for all T
.
Definition at line 59 of file Teuchos_Details_Allocator.cpp.
|
static |
Max total allocation ("high water mark") in bytes.
This count includes allocations using Allocator<T> for all T
.
Definition at line 62 of file Teuchos_Details_Allocator.cpp.
|
static |
Reset the current and max total allocation numbers to zero.
This is mainly helpful just for tests.
Definition at line 65 of file Teuchos_Details_Allocator.cpp.
|
staticprivate |
Current total allocation in bytes.
Definition at line 131 of file Teuchos_Details_Allocator.hpp.
|
staticprivate |
Max total allocation ("high water mark") in bytes.
Definition at line 134 of file Teuchos_Details_Allocator.hpp.