This is for all those STL-heads out there, this mught be trivial for you but I am a noob with the STL. I am having to implement a system in which I wil have many (thousands) of containers, I have been noticing that once you delete an element from a list memory is not released until program termination.
for the sake of argument lets say that the code looks like:
#include <iostream>
#include <list>
using namespace std;
int main(int argc, char *argv[]){
list<int> tList;
for (int i=1; i<=500000; i++){
tList.push_back(i);
cout << "i: " << i << endl;
}
cout << "tList.front(): " << tList.front() << endl;
cout << "tList.back(): " << tList.back() << endl;
list<int>::iterator Iter;
Iter = tList.begin();
// According to myself this is where I delete all elements in the list
tList.erase(Iter, tList.end());
cout << "tList.front(): " << tList.front() << endl;
cout << "tList.back(): " << tList.back() << endl;
//hold for input
int c;
do
{
c = getchar();
if(c == EOF) break;
} while(c != '\n');
}//:~
but after looking at memory, all the memory taken up by the initialization is still allocated, Is there a way of releasing this memory?