From: Geoff A. <gal...@nc...> - 2003-04-01 04:45:45
|
In running valgrind 1.0.4 against a small program of mine, valgrind = reports "still reachable" memory at exit, both with g++ 2.95.2 and gcc = 3.2 on SuSE Linux x86 7.1. I've tracked the problem down to = std::string. Here's a small program that illustrates the problem: #include <cstdlib> #include <string> int main(int argc, char* argv[]) { { std::string s; s +=3D '0'; } exit(0); } Under g++ 2.95.2, valgrind reports: =3D=3D1214=3D=3D LEAK SUMMARY: =3D=3D1214=3D=3D definitely lost: 0 bytes in 0 blocks. =3D=3D1214=3D=3D possibly lost: 0 bytes in 0 blocks. =3D=3D1214=3D=3D still reachable: 1280 bytes in 1 blocks. and under g++ 3.2, valgrind reports: =3D=3D1236=3D=3D LEAK SUMMARY: =3D=3D1236=3D=3D definitely lost: 0 bytes in 0 blocks. =3D=3D1236=3D=3D possibly lost: 0 bytes in 0 blocks. =3D=3D1236=3D=3D still reachable: 640 bytes in 1 blocks. Note that the amount of memory report as "still reachable" grows larger = as more characters are appended to s. I suspect that the "still = reachable" memory is a static buffer allocated in std::string, rather = than leaked memory. Is this correct? If so, is there way to tell = valgrind not to report the memory allocated this std::string static = buffer.=20 Thanks, Geoff Alexander |