Nebula
Loading...
Searching...
No Matches
poolarrayallocator.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
16#include "memory/memorypool.h"
17
18//------------------------------------------------------------------------------
19namespace Memory
20{
22{
23public:
25 static const SizeT NumPools = 8;
26
31
33 void Setup(const char* name, Memory::HeapType heapType, uint poolSizes[NumPools]);
35 void* Alloc(SizeT size);
37 void Free(void* ptr, SizeT size);
39 void Free(void* ptr);
41 const MemoryPool& GetMemoryPool(IndexT index) const;
42
43 #if NEBULA_MEMORY_STATS
45 void Dump();
46 #endif
47
48private:
50 const char* name;
52};
53
54} // namespace Memory
55//------------------------------------------------------------------------------
A simple thread-safe memory pool.
Allocates small memory blocks from an array of fixed-size memory pools.
Definition poolarrayallocator.h:22
void Free(void *ptr, SizeT size)
free a block of memory from the pool array with original block size
Definition poolarrayallocator.cc:107
void * Alloc(SizeT size)
allocate a block of memory from the pool
Definition poolarrayallocator.cc:74
const char * name
Definition poolarrayallocator.h:50
MemoryPool memoryPools[NumPools]
Definition poolarrayallocator.h:51
void Setup(const char *name, Memory::HeapType heapType, uint poolSizes[NumPools])
setup the pool allocator, name must be a static string!
Definition poolarrayallocator.cc:38
Memory::HeapType heapType
Definition poolarrayallocator.h:49
~PoolArrayAllocator()
destructor
Definition poolarrayallocator.cc:26
const MemoryPool & GetMemoryPool(IndexT index) const
access to memory pool at pool index (for debugging)
Definition poolarrayallocator.cc:149
PoolArrayAllocator()
constructor
Definition poolarrayallocator.cc:16
static const SizeT NumPools
number of pools
Definition poolarrayallocator.h:25
Allocates memory using the TLSF method (http://www.gii.upv.es/tlsf/files/ecrts04_tlsf....
Definition arenaallocator.h:31
HeapType
Heap types are defined here.
Definition osxmemoryconfig.h:25
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
int IndexT
Definition types.h:48