![]() |
TrinityCore
|
Classes | |
class | MemBlock |
Public Types | |
enum | { tinyBufferSize = 128, smallBufferSize = 1024, medBufferSize = 4096 } |
enum | { maxTinyBuffers = 250000, maxSmallBuffers = 40000, maxMedBuffers = 5000 } |
Public Member Functions | |
BufferPool () | |
~BufferPool () | |
UserPtr | realloc (UserPtr ptr, size_t bytes) |
UserPtr | malloc (size_t bytes) |
void | free (UserPtr ptr) |
std::string | performance () const |
std::string | status () const |
Public Attributes | |
int | totalMallocs |
int | mallocsFromTinyPool |
int | mallocsFromSmallPool |
int | mallocsFromMedPool |
volatile size_t | bytesAllocated |
Private Types | |
typedef void * | UserPtr |
typedef void * | RealPtr |
Private Member Functions | |
void | lock () |
void | unlock () |
UserPtr | tinyMalloc (size_t bytes) |
bool | inTinyHeap (UserPtr ptr) |
void | tinyFree (UserPtr ptr) |
void | flushPool (MemBlock *pool, int &poolSize) |
UserPtr | malloc (MemBlock *pool, int &poolSize, size_t bytes) |
Private Attributes | |
MemBlock | smallPool [maxSmallBuffers] |
int | smallPoolSize |
MemBlock | medPool [maxMedBuffers] |
int | medPoolSize |
void * | tinyPool [maxTinyBuffers] |
int | tinyPoolSize |
void * | tinyHeap |
Spinlock | m_lock |
|
private |
Actual block allocated on the heap
|
private |
Pointer given to the program. Unless in the tiny heap, the user size of the block is stored right in front of the pointer as a uint32.
anonymous enum |
Only store buffers up to these sizes (in bytes) in each pool-> Different pools have different management strategies.
A large block is preallocated for tiny buffers; they are used with tremendous frequency. Other buffers are allocated as demanded. Tiny buffers are 128 bytes long because that seems to align well with cache sizes on many machines.
Enumerator | |
---|---|
tinyBufferSize | |
smallBufferSize | |
medBufferSize |
anonymous enum |
Most buffers we're allowed to store. 250000 * { 128 | 256} = {32 | 64} MB (preallocated) 40000 * {1024 | 2048} = {40 | 80} MB (allocated on demand) 5000 * {4096 | 8192} = {20 | 40} MB (allocated on demand)
Enumerator | |
---|---|
maxTinyBuffers | |
maxSmallBuffers | |
maxMedBuffers |
|
inline |
----------------------------—— old mutex
-------------------------------— old mutex
|
inline |
|
inlineprivate |
|
inline |
Returns true if this is a pointer into the tiny heap.
|
inlineprivate |
Allocate out of a specific pool. Return NULL if no suitable memory was found.
|
inline |
|
inline |
|
inline |
|
inlineprivate |
|
inlineprivate |
Malloc out of the tiny heap. Returns NULL if allocation failed.
|
inlineprivate |
volatile size_t G3D::BufferPool::bytesAllocated |
Amount of memory currently allocated (according to the application). This does not count the memory still remaining in the buffer pool, but does count extra memory required for rounding off to the size of a buffer. Primarily useful for detecting leaks.
|
private |
int G3D::BufferPool::mallocsFromMedPool |
int G3D::BufferPool::mallocsFromSmallPool |
int G3D::BufferPool::mallocsFromTinyPool |
|
private |
|
private |
|
private |
|
private |
|
private |
Pointer to the data in the tiny pool
|
private |
The tiny pool is a single block of storage into which all tiny objects are allocated. This provides better locality for small objects and avoids the search time, since all tiny blocks are exactly the same size.
|
private |
int G3D::BufferPool::totalMallocs |
Count of memory allocations that have occurred.