Logo Search packages:      
Sourcecode: poco version File versions  Download package

Poco::MemoryPool Class Reference

#include <MemoryPool.h>

List of all members.

Detailed Description

A simple pool for fixed-size memory blocks.

The main purpose of this class is to speed-up memory allocations, as well as to reduce memory fragmentation in situations where the same blocks are allocated all over again, such as in server applications.

All allocated blocks are retained for future use. A limit on the number of blocks can be specified. Blocks can be preallocated.

Definition at line 52 of file MemoryPool.h.

Public Member Functions

int allocated () const
 Returns the block size.
int available () const
 Returns the number of allocated blocks.
std::size_t blockSize () const
 Releases a memory block and returns it to the pool.
void * get ()
 MemoryPool (std::size_t blockSize, int preAlloc=0, int maxAlloc=0)
void release (void *ptr)
 ~MemoryPool ()

Private Types

enum  { BLOCK_RESERVE = 128 }
typedef std::vector< char * > BlockVec

Private Member Functions

 MemoryPool (const MemoryPool &)
 MemoryPool ()
 Returns the number of available blocks in the pool.
MemoryPooloperator= (const MemoryPool &)

Private Attributes

int _allocated
BlockVec _blocks
std::size_t _blockSize
int _maxAlloc
FastMutex _mutex

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

Generated by  Doxygen 1.6.0   Back to index