Follow up to What the heque is going on with the memory overhead of std::deque?
Visual C++ manages deque
blocks according to the container element type using this:
#define _DEQUESIZ (sizeof (value_type) <= 1 ? 16 \
: sizeof (value_type) <= 2 ? 8 \
: sizeof (value_type) <= 4 ? 4 \
: sizeof (value_type) <= 8 ? 2 \
: 1) /* elements per block (a power of 2) */
This results in very large memory footprint for small elements. By changing the 16 in the first line to 128 I was able to drastically reduce the footprint required for a large deque<char>
. Process Explorer Private Bytes dropped from 181MB -> 113MB after 100m push_back(const char& mychar)
calls).
- Can anybody justify the values in
that
#define
? - How do other
compilers handle
deque
block sizing? - What would be their footprint
(32-bit operation) for the simple
test of 100m
push_back
calls todeque<char>
? - Does STL allow for
overriding of this block size at
compile-time, without modifying the
<deque>
code?