C++ Apps are prone to heap fragmentation if the programmer doesn't
take care of it and/or the allocation schemes aren't prepared for c++
allocation requests: i.e. many little allocs and many little deallocs
throughout the application invocations. On VC7, several factors
multiply:
- allocation scheme of the VC7 standard library.
- default heap settings in VC7.
Activate it this way
_set_sbh_threshold(128);
or by doing this
ULONG HeapFragValue = 2;
::HeapSetInformation((HANDLE)_get_heap_handle(),
HeapCompatibilityInformation, &HeapFragValue,
sizeof(HeapFragValue));
And you may see significant speedups in you C++ app, if your
allocation schemes are a lot of small-object allocations or your
std::vector::resize operation is simply not fast enough.
You can use a Custom allocator to tune your allocation schemes. I
actually tweaked Nicolai Josuttis Allocator template to use Doug Leas
dlmalloc Allocator (i.e. I changed _2_ lines), which speeds up things
with native stl significantly (A variation of that allocator,
ptmalloc, is used in the glibc).