62 total += current->pending();
75 if (current->size() >= size)
77 return current->pending();
83#ifdef DEBUG_BUFFER_MEMORY
85std::map<BufferBase*, void*> g_alloc_source;
111 if (size <= current->size())
113 result =
static_cast<BufferBase*
>(current->next().item);
119 if (0 && totalSize < 5000 && totalSize + current->size() >= 5000) {
122 current->allocCount_++;
141#ifdef DEBUG_BUFFER_MEMORY
167#ifdef DEBUG_BUFFER_MEMORY
170 g_alloc_source.erase(item);
175 if (item->
size() <= current->size())
177 current->insert(item);
void * buffer_malloc(size_t length)
malloc implementation used for allocating buffer space.
Pool * rawBufferPool
Use this BufferPool to allocate raw buffers.
Pool * init_main_buffer_pool()
Initializes the main buffer pool.
DynamicPool * mainBufferPool
main buffer pool instance
void * g_current_alloc
This pointer will be saved for debugging the current allocation source.
const unsigned LARGEST_BUFFERPOOL_BUCKET
Ensures that the largest bucket in the main buffer pool is exactly the size of a GenMessage.
See OSMutexLock in os/OS.hxx.
Lightweight locking class for protecting small critical sections.
This is a struct for storing info about a specific size item in the DynamicPool.
size_t size()
Get the size of the bucket.
static Bucket * init(int s,...)
Allocate a Bucket array off of the heap initialized with sizes.
Abstract base class for all Buffers.
Base class for all QMember types that hold data in an expandable format.
A specialization of a pool which can allocate new elements dynamically upon request.
void free(BufferBase *item) override
Releases an item back to the free pool.
size_t free_items() override
Number of free items in the pool.
BufferBase * alloc_untyped(size_t size, Executable *flow) override
Get a free item out of the pool.
void * alloc_large(size_t size)
Allocates a large memory block directly from the heap.
Bucket * buckets
Free buffer queue.
void free_large(void *block)
Frees a large memory block allocated by alloc_large.
An object that can be scheduled on an executor to run.
virtual void alloc_result(QMember *item)
Return the result of an alloc_async() from a memory Pool.
void free(BufferBase *item) override
Release an item back to the free pool.
bool valid(QMember *item)
Used in static pools to tell if this item is a member of the pool.
BufferBase * alloc_untyped(size_t size, Executable *flow) override
Get a free item out of the pool.
size_t itemSize
item Size for fixed pools
bool empty
is the pool empty
Q queue
Free buffer queue.
Pool of previously allocated, but currently unused, items.
friend class BufferBase
Allow BufferBase to access this class.
size_t totalSize
keep track of total allocated size of memory
void insert(QMember *item, unsigned index=0)
Add an item to the back of the queue.
bool empty(unsigned index)
Test if the queue is empty.
QMember * next(unsigned index)
Get an item from the front of the queue.
void * buffer_malloc(size_t length)
Allocates a buffer.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.