g++ has a possible memory leak
Matthias Klose
doko@cs.tu-berlin.de
Sat Nov 21 07:23:00 GMT 1998
[This bug has been reported on the Debian bug tracking system; please
see http://www.debian.org/Bugs/db/28/28626.html for more details.]
I checked it with the egcs-1.1 branch (updated 19981116) and with
egcs-2.92.21 19981116 on i486-linux and could reproduce the memory
leak when building aspell with shared libraries. Building with
egcs-2.92.21 requires the appended patch and compiling aspell.cc with
-O0 or -O1.
-mk
Message-ID: <363644EC.A454CE5F@clark.net>
Date: Tue, 27 Oct 1998 17:10:52 -0500
From: Kevin Atkinson <kevina@clark.net>
X-Mailer: Mozilla 4.5 [en] (X11; I; Linux 2.1.124 i586)
X-Accept-Language: en
MIME-Version: 1.0
To: submit@bugs.debian.org
Subject: Slink g++ ver 2.91 has a possable memory leak
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Package: g++
Version: 2.91.57-5
Severity: important
I think have discovered a memory leak in g++ which seams to be present
ONLY in the debian package version of g++ 2.91 as when I downloaded and
compiled egcs 1.1b myself (with no special options except that prefix
was set to /usr/local) and recompiled my program the memory leak was no
longer present. Also, the memory leak was also not present when
compiled with g++ 2.90.29-0.6.
Unfortunately I have not bean able to isolate the problem. However it is
very easy to reproduce:
Download aspell from http://sunsite.unc.edu/kevina/aspell/ unpack
type ./configure or ./configure --disable-static
make
make memleak-test
Then run memleak-test and monitor its size with top or some other utility.
It should grow in size for the first couple of seconds while the hash tables
get loaded however after that it should stay the same.
I am 99% sure this is a problem with egcs and not my code however I have
only been programing in c++ for about a year or so. If it is a problem
with my code and not egcs please let me know.
Also if you can not reproduce the problem on your system let me know and
I will send you a statically linked binary. And if that doesn't work I
will give you an account on my system.
*** gen_lang_loader.cc.old Tue Oct 27 03:49:00 1998
--- gen_lang_loader.cc Sat Nov 21 15:20:21 1998
***************
*** 1,4 ****
-
#include "gen_lang_loader.hh"
#include <iostream.h>
#include <fstream.h>
--- 1,3 ----
***************
*** 84,90 ****
}
void SC_GenericLangLoader::print_code_to_file() {
! print_code_header(ofstream( ("asl_" + name_intr + ".hh").c_str() ));
ofstream file( ("asl_" + name_intr + ".cc").c_str() );
file << endl;
file << "#include \"language.hh\"" << endl;
--- 83,90 ----
}
void SC_GenericLangLoader::print_code_to_file() {
! ofstream os( ("asl_" + name_intr + ".hh").c_str() );
! print_code_header(os);
ofstream file( ("asl_" + name_intr + ".cc").c_str() );
file << endl;
file << "#include \"language.hh\"" << endl;
***************
*** 104,110 ****
out << endl;
}
! void SC_GenericLangLoader::print_code_header(ostream &out = cout) {
string nname = name_intr;
nname[0] = to_upper(nname[0]);
print_code_header("SC_" + nname, out);
--- 104,110 ----
out << endl;
}
! void SC_GenericLangLoader::print_code_header(ostream &out) {
string nname = name_intr;
nname[0] = to_upper(nname[0]);
print_code_header("SC_" + nname, out);
***************
*** 130,136 ****
}
void SC_GenericLangLoader::print_code_body(const string &class_name,
! ostream &out = cout) {
out << endl;
out << "class " << class_name << " : public SC_Language {" << endl;
out << "private:" << endl;
--- 130,136 ----
}
void SC_GenericLangLoader::print_code_body(const string &class_name,
! ostream &out) {
out << endl;
out << "class " << class_name << " : public SC_Language {" << endl;
out << "private:" << endl;
***************
*** 169,175 ****
out << endl;
}
! void SC_GenericLangLoader::print_code_body(ostream &out = cout) {
string nname = name_intr;
nname[0] = to_upper(nname[0]);
print_code_body("SC_" + nname, out);
--- 169,175 ----
out << endl;
}
! void SC_GenericLangLoader::print_code_body(ostream &out) {
string nname = name_intr;
nname[0] = to_upper(nname[0]);
print_code_body("SC_" + nname, out);
More information about the Gcc-bugs
mailing list