Nebula
|
#include <arenaallocator.h>
Allocates memory in chunks.
This allocator creates memory in user-specified (default 65535) byte chunks. Each time an object is requested, the current chunk is checked for storage, and if the object fits, an iterator is progressed with the size of the object, after which a pointer to the allocated space is returned. If the object does not fit, the allocator creates a new chunk, and retires the old, without considering the potential space lost in the process.
This type of allocator allows for several objects of different types to be allocated linearly in memory, thus providing a cache-friendly access pattern for places where memory allocation is somewhat deterministic.
Public Member Functions | |
ArenaAllocator () | |
constructor | |
~ArenaAllocator () | |
destructor | |
ArenaAllocator (const ArenaAllocator &rhs) | |
copy constructor | |
void | operator= (const ArenaAllocator &rhs) |
assignment operator | |
ArenaAllocator (ArenaAllocator &&rhs) | |
move constructor | |
void | operator= (ArenaAllocator &&rhs) |
move operator | |
template<typename T > | |
T * | Alloc () |
allocate new object, and calls constructor, but beware because this allocator does not run the destructors | |
template<typename T > | |
T * | Alloc (SizeT num) |
Allocate several new objects of a specific type. | |
void * | Alloc (SizeT size) |
allocate new chunk of size | |
void | NewChunk () |
retires a chunk and creates a new one (might waste memory) | |
void | Release () |
release all memory | |
Private Attributes | |
byte * | currentChunk |
byte * | iterator |
Util::Array< byte * > | retiredChunks |
|
inline |
constructor
|
inline |
destructor
|
inline |
copy constructor
|
inline |
move constructor
|
inline |
allocate new object, and calls constructor, but beware because this allocator does not run the destructors
|
inline |
Allocate several new objects of a specific type.
|
inline |
allocate new chunk of size
|
inline |
retires a chunk and creates a new one (might waste memory)
|
inline |
move operator
|
inline |
assignment operator
|
inline |
release all memory
|
private |
|
private |
|
private |