41 template <
typename Data>
42 static void allocate(Data*& ptr,
size_t size);
56 template <
typename Data>
57 static void deallocate(Data*& ptr,
size_t size);
73 template <
typename Data>
74 static void reallocate(Data*& ptr,
size_t oldSize,
size_t newSize);
95 static long int total();
102 static long int max();
108 static long int max(MPI::Intracomm& communicator);
119 static long int total_;
122 static long int max_;
125 static long int nAllocate_;
128 static long int nDeallocate_;
135 template <
typename Data>
139 UTIL_THROW(
"Attempt to allocate to non-null pointer");
142 ptr =
new Data[size];
144 total_ += size *
sizeof(Data);
146 if (total_ > max_) max_ = total_;
147 }
catch (std::bad_alloc&) {
148 std::cout <<
"Allocation error in Util::Memory" << std::endl;
156 template <
typename Data>
165 long int change = size *
sizeof(Data);
174 template <
typename Data>
180 Data* newPtr =
nullptr;
184 for (
size_t i = 0; i < oldSize; ++i) {
Provides method to allocate array.
static long int nDeallocate()
Return number of times deallocate() was called.
static void deallocate(Data *&ptr, size_t size)
Deallocate a C++ array.
static long int nAllocate()
Return number of times allocate() was called.
static long int max()
Return the maximum amount of allocated heap memory thus far.
static long int total()
Return total amount of memory currently allocated.
static void reallocate(Data *&ptr, size_t oldSize, size_t newSize)
Reallocate a C++ array.
static void initStatic()
Call this just to guarantee initialization of static memory.
static void allocate(Data *&ptr, size_t size)
Allocate a C++ array.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.