Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
|
Optional tracking allocator for Teuchos Memory Management classes. More...
#include <Teuchos_Details_Allocator.hpp>
Classes | |
struct | rebind |
Mapping to an Allocator for a different type U . More... | |
Public Types | |
typedef T | value_type |
Type of the template parameter of this class. More... | |
typedef T * | pointer |
Type of a pointer to T. More... | |
typedef const T * | const_pointer |
Type of a pointer to const T. More... | |
typedef T & | reference |
Type of a reference to T. More... | |
typedef const T & | const_reference |
Type of a reference to const T. More... | |
typedef AllocationLogger::size_type | size_type |
Type of the size of an allocation or deallocation. More... | |
typedef std::ptrdiff_t | difference_type |
Integer type representing the difference between two pointers. More... | |
Public Member Functions | |
Allocator () | |
Default constructor. More... | |
Allocator (const bool trackMemory, const bool verboseOutput) | |
Constructor. More... | |
template<class U > | |
Allocator (const Allocator< U > &src) | |
Copy constructor that takes an Allocator<U> for any U. More... | |
size_type | max_size () const |
Upper bound (possibly loose) on maximum allocation size. More... | |
value_type * | allocate (const size_type &n, const void *=0) |
Allocate an array of n instances of value_type. More... | |
void | deallocate (value_type *p, const size_type &n) |
Deallocate n instances of value_type. More... | |
size_type | curAllocInBytes () |
Current total allocation in bytes, over all Allocator<U>. More... | |
size_type | maxAllocInBytes () |
Max total allocation ("high water mark") in bytes, over all Allocator<U>. More... | |
void | construct (pointer p, const_reference val) |
Invoke the constructor of an instance of T , without allocating. More... | |
void | destroy (pointer p) |
Invoke the destructor of an instance of T , without deallocating. More... | |
Private Types | |
enum | EAllocatorOp { ALLOCATOR_ALLOCATE, ALLOCATOR_DEALLOCATE } |
Internal enum, identifying whether an operation is an allocation or a deallocation. More... | |
Private Member Functions | |
bool | tracking () const |
Whether this Allocator logs. More... | |
bool | verbose () const |
Whether this allocator prints verbosely. More... | |
Private Attributes | |
bool | track_ |
bool | verbose_ |
Friends | |
template<class U > | |
class | Allocator |
Optional tracking allocator for Teuchos Memory Management classes.
T | The type of the entries in arrays to allocate. |
This class implements the C++ Standard Library's "Allocator" concept. It does "high water mark" tracking, and has the option to print to stderr
on allocations and deallocations.
Definition at line 156 of file Teuchos_Details_Allocator.hpp.
typedef T Teuchos::Details::Allocator< T >::value_type |
Type of the template parameter of this class.
Definition at line 178 of file Teuchos_Details_Allocator.hpp.
typedef T* Teuchos::Details::Allocator< T >::pointer |
Type of a pointer to T.
This is only needed for C++98, not for C++11 and newer.
Definition at line 183 of file Teuchos_Details_Allocator.hpp.
typedef const T* Teuchos::Details::Allocator< T >::const_pointer |
Type of a pointer to const T.
This is only needed for C++98, not for C++11 and newer.
Definition at line 187 of file Teuchos_Details_Allocator.hpp.
typedef T& Teuchos::Details::Allocator< T >::reference |
Type of a reference to T.
This is only needed for C++98, not for C++11 and newer.
Definition at line 191 of file Teuchos_Details_Allocator.hpp.
typedef const T& Teuchos::Details::Allocator< T >::const_reference |
Type of a reference to const T.
This is only needed for C++98, not for C++11 and newer.
Definition at line 195 of file Teuchos_Details_Allocator.hpp.
typedef AllocationLogger::size_type Teuchos::Details::Allocator< T >::size_type |
Type of the size of an allocation or deallocation.
This must match AllocationLogger::size_type (see above). If we didn't need this to have the same type as that, then we wouldn't need this typedef.
Definition at line 202 of file Teuchos_Details_Allocator.hpp.
Teuchos::Details::Allocator< T >::difference_type |
Integer type representing the difference between two pointers.
This is only needed for C++98, not for C++11 and newer. However, we want this typedef to exist in both cases. Thus, if C++11 is enabled, we use size_type above to compute this, in order to ensure consistency.
Definition at line 214 of file Teuchos_Details_Allocator.hpp.
|
private |
Internal enum, identifying whether an operation is an allocation or a deallocation.
Enumerator | |
---|---|
ALLOCATOR_ALLOCATE | |
ALLOCATOR_DEALLOCATE |
Definition at line 160 of file Teuchos_Details_Allocator.hpp.
|
inline |
Default constructor.
Definition at line 218 of file Teuchos_Details_Allocator.hpp.
|
inline |
Constructor.
trackMemory | [in] Whether to track memory usage at all. If false, verboseOutput is ignored. |
verboseOutput | [in] Whether to print on every allocation and deallocation. Even if this is true, trackMemory must also be true in order for this to work. |
Definition at line 229 of file Teuchos_Details_Allocator.hpp.
|
inline |
Copy constructor that takes an Allocator<U> for any U.
Definition at line 236 of file Teuchos_Details_Allocator.hpp.
|
inlineprivate |
Whether this Allocator logs.
Definition at line 166 of file Teuchos_Details_Allocator.hpp.
|
inlineprivate |
Whether this allocator prints verbosely.
Definition at line 169 of file Teuchos_Details_Allocator.hpp.
|
inline |
Upper bound (possibly loose) on maximum allocation size.
Implementations of the Allocator concept should not NEED this method, but it makes the Clang compiler happy.
Definition at line 256 of file Teuchos_Details_Allocator.hpp.
|
inline |
Allocate an array of n instances of value_type.
n | [in] Number of entries in the array. |
The optional second argument provides an "allocation hint." This implementation ignores the hint.
Definition at line 268 of file Teuchos_Details_Allocator.hpp.
|
inline |
Deallocate n instances of value_type.
p | [in] Pointer to the array to deallocate. |
n | [in] Number of entries in the array p. |
Definition at line 280 of file Teuchos_Details_Allocator.hpp.
|
inline |
Current total allocation in bytes, over all Allocator<U>.
Definition at line 292 of file Teuchos_Details_Allocator.hpp.
|
inline |
Max total allocation ("high water mark") in bytes, over all Allocator<U>.
Definition at line 297 of file Teuchos_Details_Allocator.hpp.
|
inline |
Invoke the constructor of an instance of T
, without allocating.
p | [in] Pointer to an area of memory in which to construct a T instance, using placement new. |
val | [in] Argument to T's (copy) constructor. |
Definition at line 313 of file Teuchos_Details_Allocator.hpp.
|
inline |
Invoke the destructor of an instance of T
, without deallocating.
p | [in] Pointer to an instance of T to destroy. |
Definition at line 328 of file Teuchos_Details_Allocator.hpp.
Definition at line 174 of file Teuchos_Details_Allocator.hpp.
|
private |
Definition at line 334 of file Teuchos_Details_Allocator.hpp.
|
private |
Definition at line 335 of file Teuchos_Details_Allocator.hpp.