If you run into a situation that you need to allocate a specific object very frequently. Obviously the traditional way will cause the memory fragment because of
frequent allocation on heap, and you will get more risk for failure of allocation after a certain running period. so this situation the memory pool definately is your
best choice.
I got this situation on my open source project. A lot of client will connect and disconnect the server occasionally. I need to allocate a chunk of heap memory
for each connecting, and recycle the memeory when disconnecting. so I came up with a very simple and effective memory pool to address this problem.Here is the code .
By the way , in the first place I wanted to use the BitSet in place of Vector. But Bitset in C++ 11 can not support dynamically size changing. And sound like the compiler
will optimize the vector as a bitset. so I think the vector is the right answer for this class.