Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: twilger@aol.com (Twilger)
Subject: C++ Bug? STL associative containers (map, set, ...)
Date: 1997/04/05	[thread overview]
Message-ID: <19970405165400.LAA08133@ladder01.news.aol.com> (raw)


I am having a problem with a memory leak when I use one of the associative
containers such as map or set in the Standard Template Library. This
problem occures on a Digital Alpha running Digital Unix 3.2D-1 and DEC C++
5.4. Actually, it's more like a river than a leak! The problem occures
when I have a class which contains more than one instance of a particular
associative container.
Exmaple:

class foo
{
   map<int, int, less<int> > x1;
   map<int, int, less<int> > x2;
};

int main()
{
   foo *pMyfoo;
   while (1)
   {
      pMyfoo = new foo();
      delete pMyfoo;
   }
}

When I run this, even though I call delete on pMyfoo, the memory being
used is not getting completely released, eventually causing the program to
run out of heap. If I change the class foo to have only one instance of a
map, the problem goes away. Also, when I use other containers such as
vector or deque in place of map, I don't have any problems. I tried to
replicate this problem using Visual C++ 4.2 on an Intel machine, but it
worked fine. Does anybody have an idea what is going on?

I am not always able to check this news group :( 
if you can answer this could you send the response to:
tom.wilger@coors.com

Thanks



                 reply	other threads:[~1997-04-05  5:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox