help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

std::List doesn't releases the memory ...


From: RV
Subject: std::List doesn't releases the memory ...
Date: Sun, 5 Jul 2009 23:19:51 -0700 (PDT)
User-agent: G2/1.0

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
--


reply via email to

[Prev in Thread] Current Thread [Next in Thread]