38 template <
typename Data>
39 static void allocate(Data*& ptr,
size_t size);
47 template <
typename Data>
48 static void deallocate(Data*& ptr,
size_t size);
76 static int max(MPI::Intracomm& communicator);
93 static int nAllocate_;
96 static int nDeallocate_;
103 template <
typename Data>
107 UTIL_THROW(
"Attempt to allocate to non-null pointer");
110 ptr =
new Data[size];
111 total_ += (size*
sizeof(Data));
113 if (total_ > max_) max_ = total_;
114 }
catch (std::bad_alloc&) {
115 std::cout <<
"Allocation error" << std::endl;
123 template <
typename Data>
129 total_ -= size*
sizeof(Data);
132 UTIL_THROW(
"Attempt to de-allocate null pointer");
static int total()
Return total amount of memory currently allocated.
static int nAllocate()
Return number of times allocated was called.
static void initStatic()
Call this just to guarantee initialization of static memory.
File containing preprocessor macros for error handling.
static int nDeallocate()
Return number of times deallocate was called.
static void allocate(Data *&ptr, size_t size)
Allocate a C array.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.
Provides method to allocate array.
static int max()
Return the maximum amount of allocated heap memory thus far.
static void deallocate(Data *&ptr, size_t size)
Allocate a C array.