Re:PHP's ob_start() pre-allocates 40k memory per call
by jemfinch on Thursday December 08, 2011 @10:31AM
(#3329436)
Depending on the number of objects you're allocating, it's often better (for reduced fragmentation and smooth performance) to use an allocation strategy like GCC's std::deque: allocate fixed-size buffers, and use an exponentially growing array to hold pointers to those buffers. Once you start getting into millions of elements in your std::vector, you'll see long program pauses (as the vector grows and all the elements are copied to the new vector) and sometimes have difficulty finding a large enough contiguous buffer.
This is one reason why the C++ cognoscenti recommend using std::deque as your default array-like container rather than std::vector.
This is one reason why the C++ cognoscenti recommend using std::deque as your default array-like container rather than std::vector.