Memory Allocators
Accumulating buffer
Accumulating buffer is very common paradigm to accumulate some kind of data, which is transferred via network sockets or pipes, and then to analyze it when all parts of message is received. This class implements such algorithm, and do necessary memory management to allow the buffer to grow more and more, until all the data are received. It may reallocate the buffer position during free space reservation. So, please, be careful when use old pointers to the buffer after calling the space reserving function.
- Constructor
- Copy constructor
- Destructor
- Accumulator functions
- Reserve space into the buffer
- Fill reservered space into the buffer
- Get pointer to the buffer
- Clear the buffer
- Accumulator properties
- Accumulator capacity
- Accumulator size
- Check if accumulator is empty
- Check if accumulator is initialized
Object pool
The object pool is a set of pre allocated objects kept ready to use, rather than allocating and destroying them on demand. A client of the pool requests an object from the pool and perform operations on the returned object. When the client has finished, it returns the object to the pool rather than destroying it.
Object pooling can offer a significant performance boost in situations where the cost of initializing a class instance is high, the rate of instantiation of a class is high, and the number of instances in use at any one time is low. The pooled object is obtained in predictable time when creation of the new objects may take variable time.