bug-gplusplus
[Top][All Lists]
Advanced

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

memory leak in STL vector?


From: Thomas Hamelryck
Subject: memory leak in STL vector?
Date: 5 Jun 2002 08:58:23 GMT
User-agent: tin/pre-1.4-980514 (UNIX) (SunOS/5.7 (sun4u))

Hi,
 
I think I've come across a bug in the STL vector implementation
of g++ (g++ 2.95, g++ 2.96, on Mandrake Linux). The problem is a
meory leak in vector. When I test the following small test program
with ccmalloc (a memory leak identifier), a memory leak is reported:
 
#include <vector>
 
int main(void)
{
        int i;
        vector<int> v;
 
        for (i=0; i<100; i++)
        {
                v.push_back(i);
        }
}
 
Compilation:
 
g++ -ansi -pedantic-errors -Wall -g -p t.C -o t -lccmalloc -ldl
 
ccmalloc output :
 
*100.0% = 6848 Bytes of garbage allocated in 3 allocations
|       |
|       |       0x400abcbe in <???>
|       |
|       |       0x08049b18 in <main>
|       |                  at t.C:10
|       |
|       |       0x0805500f in <vector<int, allocator<int>
|       |                  at 
/usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../|       |
|       |       0x08054af8 in <vector<int, allocator<int>
|       |                  at 
/usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../|       |
|       |       0x08054881 in <_Vector_alloc_base<int, allocator<int>
|       |                  at 
/usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../|       |
|       |       0x08054848 in <simple_alloc<int, __default_alloc_template<true,
|       |                  at 
/usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../|       |
|       |       0x08054796 in <__default_alloc_template<true, 0>
|       |                  at 
/usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../|       |
|       |       0x08054677 in <__default_alloc_template<true, 0>
|       |                  at 
/usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../|       |
|       |       0x08054542 in <__default_alloc_template<true, 0>
|       |                  at 
/usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../|       |
|       `-----> 0x08049ea2 in <malloc>
|                          at src/wrapper.c:284
|
`------------------------------------------------------     

Cheers,

-Thomas








reply via email to

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