My Project
Public Types | Public Member Functions | Static Public Attributes | List of all members
NPL::CNPLStateMemAllocator Class Reference

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...
 

Detailed Description

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.

Member Function Documentation

§ deallocate()

void NPL::CNPLStateMemAllocator::deallocate ( void *const  ptr,
const size_t  n 
)

free an old buffer.

Member Data Documentation

§ s_pool_count

const int NPL::CNPLStateMemAllocator::s_pool_count = 4
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

§ s_pool_init_size_bytes

const int NPL::CNPLStateMemAllocator::s_pool_init_size_bytes = 32
static

the initial smallest fixed sized chunk that the memory pool will create.

default to 32 bytes


The documentation for this class was generated from the following files: