G
~Gee
Hi Folks!
Please see the program below:
1 #include<iostream>
2 #include<list>
3 #include <unistd.h>
4 using namespace std;
5 int main()
6 {
7 {
8 list<int> tempList;
9
10 cout << "going to start adding now ..." << endl;
11 for(long i=0; i<= 1000000; i++)
12 {
13 tempList.push_back(i);
14 }
15 cout << "done adding." << endl;
16 sleep(10);
17 }
18
19 cout << "out of scope" << endl;
20 sleep(10);
21 return 0;
22 }
When I run this program with top running, I see that even after line
19 is printed the memory(which top returns as 16 M) is not returned to
the operating system(Red Hat Linux 9.). I understand that this is an
optimization by STL to cache the memory for future use, but is it
possible to make STL return this memory to the OS (say using a system
call)?
Any inputs appreciated.
Thanks!
Please see the program below:
1 #include<iostream>
2 #include<list>
3 #include <unistd.h>
4 using namespace std;
5 int main()
6 {
7 {
8 list<int> tempList;
9
10 cout << "going to start adding now ..." << endl;
11 for(long i=0; i<= 1000000; i++)
12 {
13 tempList.push_back(i);
14 }
15 cout << "done adding." << endl;
16 sleep(10);
17 }
18
19 cout << "out of scope" << endl;
20 sleep(10);
21 return 0;
22 }
When I run this program with top running, I see that even after line
19 is printed the memory(which top returns as 16 M) is not returned to
the operating system(Red Hat Linux 9.). I understand that this is an
optimization by STL to cache the memory for future use, but is it
possible to make STL return this memory to the OS (say using a system
call)?
Any inputs appreciated.
Thanks!