Libstdc++-v3 memory leakage?

Wu Yongwei adah@netstd.com
Tue Mar 11 07:23:00 GMT 2003


I encountered some memory leakage using "gcc version 3.2.2 (mingw 
special 20030208-1)", and I reduced it to the following simple test case:

--- begin test.cpp ---
#include <vector>
#include "debug_new.h"

using std::vector;

int main()
{
	vector<int> v;
//	v.reserve(33);
	v.push_back(1);
	v.push_back(2);
}
---  end test.cpp  ---

debug_new.cpp and debug_new.h are my simple leakage detector.  They are 
not directly related to this problem.  One may use any leakage detector, 
I suppose.  For the ease of reproducing the problem, I attached them 
here.  The command line I use is simply "g++ test.cpp debug_new.cpp".

One point to notice is that if I uncomment the "reserve" line, the leak 
is gone.  If I change 33 to 32, the leak comes back.

I know that not all kind of memory leakage will cause problems, but 1) I 
need to be assured of the harmlessness; and 2) the leakage report 
defeats my purpose to easily catch my own memory leaks, because it is 
hard to tell which is caused by which.

This problem does not seem to exist in the libstdc++ w/ GCC 2.95.3, nor 
in SGI STL or STLport.

I never posted to libstdc++, and apologize for any ignorances.  I 
searched for leakage in the list but did not find any relevant infomation.

Best regards,

Wu Yongwei
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: debug_new.cpp
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030311/b0e24538/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: debug_new.h
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030311/b0e24538/attachment.h>


More information about the Libstdc++ mailing list