i'm creating a tree of small objects (1-2 KB in size) but the number of elements can be more than 2 millions. After creating the tree I've to process each item and this processing require some memory buffers of 1 to 4 MB. The allocation of these buffers is failed because the memory is fragmented.
I also delete upto 100,000 elements when std::bad_alloc exception is caught but even that does not provide enough contagious memory for 1 or 2 MB buffer.
I can't preallocate the memory for future user. Is there any way to de-fragment the memory in Visual C++ on 32-bit windows?