Topic: std::List doesn't releases the memory ...
Author: RV <rahul.vakil@gmail.com>
Date: Mon, 6 Jul 2009 09:33:18 CST Raw View
[ Moderator's note: This question just barely fits within
the charter of this newsgroup, since it asks about correct
usage. Poster: Please review the newsgroup FAQ, section A.
The URL is at the bottom of every article. -sdc
]
Hi,
I ran the following source code on linux GNU C++ compiler version (g++
(GCC) 3.4.3)
#include <iostream>
#include <list>
void PopulateList(std::list<int> & li, int numitr)
{
for(int i = 0; i < numitr; i++){
li.push_back(i);
}
}
void testList()
{
char ch;
int numitr;
std::list<int> li;
std::cout << "Enter any charater to continue : Before
Populating std::list<int> : take memory reading: ";
std::cin >> ch;
std::cout << "How many iteration: ";
std::cin >> numitr;
PopulateList(li, numitr);
std::cout << "Press any charater to continue : After
Populating std::list<int> : take memory reading: ";
std::cin >> ch;
li.clear();
std::cout << "Press any character to continue : After
clearing std::list<int> : take memory reading: ";
std::cin >> ch;
}
int main()
{
while(1) {
testList();
std::cout << "==>\n";
std::cout << "==> End of While\n";
std::cout << "==>\n";
}// End of While
}
OBSERVATION:
The memory is not getting release if the code is ran multiple times.
It seems there is a problem with std::List library. If vector is used
it releases the memory.
Can anyone please let me know about the issue or suggest solution for
this?
Is this the bug or incorrect usage?
Same code on windows run with memory gets release on each call to
testList()
Thank and With Warm Regards,
-RV
--
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]