Using the memorypool class

The memorypool class implements a pool of memory that starts with an initial buffer and grows dynamically as needed. Each time the pool is freed, the dynamic buffers are deallocated. After a configurable number of free's, the initial buffer is resized to the average amount of memory that was requested between free's since the last time it resized.

The memorypool class is especially useful for applications that do the same task over and over where varying amounts of memory are required during each iteration. The class is particularly efficient in cases where memory requirements are fairly constant between iterations with sporadic requirements for lots of memory or where the memory requirements steadily get larger or smaller across iterations.

Using a memorypool can be faster than allocating memory on demand, then deallocating it later and more efficient than using static buffers that are large enough to contain the largest possible data.

The following code connects to a server on the local machine and reads variable/value pairs from it.

int main(int argc, const char **argv) {
}