![]() |
PEARL
Parallel Event Access and Replay Library
|
Provides a base class for small objects using a custom memory management. More...
#include <pearl/SmallObject.h>
Static Public Member Functions | |
Memory allocation operators | |
static void * | operator new (std::size_t objectSize) throw (std::bad_alloc) |
Allocate storage space. | |
static void | operator delete (void *deadObject, std::size_t objectSize) |
Deallocate storage space. | |
Protected Member Functions | |
Constructors & destructor | |
~SmallObject () | |
Destructor. |
Each dynamically allocated memory block usually requires some extra memory for bookkeeping purposes. However, this can be quite space inefficient if a large number of small objects is allocated, as the per-object overhead is significant.
The SmallObject class serves as a base class that can be used for these kind of small objects, providing a customized memory management that allocates memory in larger chunks rather than individually for each object. This specialized memory management is restricted to objects of not more than 64 bytes, however, if objects grow larger (e.g., objects of a derived class) the default memory allocation routines are used transparently.
pearl::SmallObject::~SmallObject | ( | ) | [protected] |
Releases all allocated resources and destroys the instance.
static void pearl::SmallObject::operator delete | ( | void * | deadObject, |
std::size_t | objectSize | ||
) | [static] |
Deallocates the memory block pointed to by deadObject if it is non-null, releasing memory previously allocated by a call to operator new. If deadObject is NULL, this operator is a no-op.
deadObject | Pointer to memory block to be released |
objectSize | Size of the memory block in bytes |
static void* pearl::SmallObject::operator new | ( | std::size_t | objectSize | ) | throw (std::bad_alloc) [static] |
Allocates objectSize bytes of storage space and returns a non-null pointer to the first byte of the block. An optimized allocator is used for small objects less than 64 bytes, the default memory allocator otherwise.
objectSize | Size of the requested memory block in bytes |
bad_alloc | if the memory allocation cannot be fulfilled |
![]() |
Copyright © 1998–2014 Forschungszentrum Jülich GmbH,
Jülich Supercomputing Centre
Copyright © 2009–2014 German Research School for Simulation Sciences GmbH, Laboratory for Parallel Programming |