Hi!
I hope you could help me with this one. I simplified the code of my program to its basic problem, and the problem is that I do not seem to understand why this program does not release its memory. I check it at the moments of the getline
's, using Ubuntu's System Monitor.
I claim 1000 array's of 1000 items, containing int's. That consumes 4M, and that is what the System Monitor indicates. But when I try to free memory, this does not seem to help. Why? Is it because I do not free memory appropriately, or is the used space never claimed back by the operating system?
Thanks in advance for your help!
Bart.
class C
{
public:
int *bla;
C() {bla = new int[1000];}
~C() {delete[] bla;}
};
int main(int argc, char *argv[])
{
string t;
set<C*>* pSet;
set<C*>::iterator iter;
pSet = new set<C*>;
getline(cin, t);
for (int i=0; i<1000; i++)
{
pSet->insert(new C());
}
getline(cin, t);
for (iter=pSet->begin(); iter!=pSet->end(); ++iter)
{
delete *iter;
}
getline(cin, t);
pSet->clear();
getline(cin, t);
delete pSet;
getline(cin, t);
return 0;
}