My Project
|
memory allocator for NPL runtime state. More...
#include <NPLStateMemAllocator.h>
Public Types | |
typedef boost::pool | pool_type |
Public Member Functions | |
void * | allocate (void *ptr, size_t nsize) |
allocate a new buffer | |
void * | reallocate (void *ptr, size_t osize, size_t nsize) |
reallocate a buffer, old buffer content are copied to new buffer is necessary | |
void | deallocate (void *const ptr, const size_t n) |
free an old buffer. More... | |
Static Public Attributes | |
static const int | s_pool_init_size_bytes = 32 |
the initial smallest fixed sized chunk that the memory pool will create. More... | |
static const int | s_pool_init_size = 5 |
this should be log2(s_pool_init_size_bytes) | |
static const int | s_pool_count = 4 |
how many free lists are there in the pool. More... | |
memory allocator for NPL runtime state.
Since NPL state is single threaded, no lock is needed for this memory allocator. This should be the fastest memory allocator on earth. Internal it uses memory pool of predefined sizes. Sizes are 32,64,128,256,512,1024,2048; we will use the default allocator for sizes over 2048. Most lua objects are 20-30 bytes; and most allocates are 32,64, 128, 256.
void NPL::CNPLStateMemAllocator::deallocate | ( | void *const | ptr, |
const size_t | n | ||
) |
free an old buffer.
|
static |
how many free lists are there in the pool.
s_pool_init_size_bytes^2 is the biggest chunk. currently it is 2048 bytes
|
static |
the initial smallest fixed sized chunk that the memory pool will create.
default to 32 bytes