Hi,

I have compiled the following source code on SuSE linux with g++
compiler version 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 multiple iteration of while loop doesn't release the memory
occupied by the std::list

Is this a bug with std::List or incorrect usage of it?

The same behaviour is not observed with std::vector?

Does anyone knows the solution for this?

Thanks and With Warm Regards,

-RV
--
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to