27#define SMALL_CHUNK 0x100
28#define MEDIUM_CHUNK 0x1000
29#define BIG_CHUNK 0x10000
34template <
int ChunkSize>
54 template <
typename T> T*
Alloc();
73template <
int ChunkSize>
85template <
int ChunkSize>
95template<
int ChunkSize>
103 rhs.retiredChunks.Clear();
104 rhs.currentChunk =
nullptr;
105 rhs.iterator =
nullptr;
111template<
int ChunkSize>
124template<
int ChunkSize>
132 rhs.retiredChunks.Clear();
133 rhs.currentChunk =
nullptr;
134 rhs.iterator =
nullptr;
140template<
int ChunkSize>
152template <
int ChunkSize>
165template<
int ChunkSize>
183template <
int ChunkSize>
189 if constexpr (
sizeof(T) > ChunkSize)
208 if (remainder < alignedSize)
221template <
int ChunkSize>
227 if constexpr (
sizeof(T) > ChunkSize)
232 ret =
new (block) T[num];
246 if (remainder < alignedSize)
259template <
int ChunkSize>
265 if (size > ChunkSize)
283 if (remainder < size)
~ArenaAllocator()
destructor
Definition arenaallocator.h:87
void * Alloc(SizeT size)
allocate new chunk of size
Definition arenaallocator.h:261
T * Alloc()
allocate new object, and calls constructor, but beware because this allocator does not run the destru...
Definition arenaallocator.h:186
ArenaAllocator()
constructor
Definition arenaallocator.h:75
ArenaAllocator(ArenaAllocator &&rhs)
move constructor
Definition arenaallocator.h:97
ArenaAllocator(const ArenaAllocator &rhs)
copy constructor
Definition arenaallocator.h:113
void operator=(const ArenaAllocator &rhs)
assignment operator
Definition arenaallocator.h:142
byte * currentChunk
Definition arenaallocator.h:65
void operator=(ArenaAllocator &&rhs)
move operator
Definition arenaallocator.h:126
Util::Array< byte * > retiredChunks
Definition arenaallocator.h:67
T * Alloc(SizeT num)
Allocate several new objects of a specific type.
Definition arenaallocator.h:224
byte * iterator
Definition arenaallocator.h:66
void Release()
release all memory
Definition arenaallocator.h:166
void NewChunk()
retires a chunk and creates a new one (might waste memory)
Definition arenaallocator.h:154
Nebula's dynamic array class.
Definition array.h:60
#define n_assert(exp)
Definition debug.h:50
Nebula compiler specific defines and configuration.
__forceinline unsigned int align(unsigned int alignant, unsigned int alignment)
Definition scalar.h:731
Definition arenaallocator.h:31
void * Alloc(HeapType heapType, size_t size, size_t alignment)
Allocate a block of memory from one of the global heaps.
Definition osxmemory.cc:56
void Free(HeapType heapType, void *ptr)
Free a block of memory.
Definition osxmemory.cc:136
@ ObjectArrayHeap
Definition osxmemoryconfig.h:28
Nebula's scalar datatype.
ptrdiff PtrDiff
Definition types.h:53
int SizeT
Definition types.h:49
int IndexT
Definition types.h:48