In our software we are using Associative Containers
to store a huge amount of items in some situations.
For example at one point we are using a STL set to store
a huge amount of strings.
Memory used by this STL set is often more than 200 MB.
When the set goes out of scope, all memory used by the set gets deallocated
Using a Memory-Tool shows that all the deallocated memory
ends up in "Reserved Memory" and not in "Free Memory".
STL map shows the same effect.
Here is some sample code:
// At this point reserved memory is 3 MB
for (int i=0; i<2000000; i++)
std::string str (tmp);
// At this point reserved memory is 258 MB
Such huge STL Containers only needed a few times in our software.
Mostly associative containers with moderate sizes are needed.
The problem is:
At this point there are several hundred MB of memory
reserved by the system for future use (with associative containers?).
The reserved memory is not available for other operations.
Is there a way to deallocate the memory
,used by a Associative Container,
so that memory is given completely back
to the "Free Memory" ?
Thanks for any help!