From: Lee, H. <HJ...@ec...> - 2003-04-26 00:03:31
|
Hi, If I use string type for example ---> string a("Hello, world"), the memory allocated for string isn't freed when program exit. valgrand reported it is not-freed block. Here is valgrind reports logs. Why is it not freed when program exits? I am using RH6.2. ---------------- ==2264== Addrcheck, a fine-grained address checker for x86-linux. ==2264== Copyright (C) 2002, and GNU GPL'd, by Julian Seward. ==2264== Using valgrind-1.9.5, a program instrumentation system for x86-linux. ==2264== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward. ==2264== ==2264== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==2264== malloc/free: in use at exit: 1280 bytes in 1 blocks. ==2264== malloc/free: 1 allocs, 0 frees, 1280 bytes allocated. ==2264== For counts of detected errors, rerun with: -v ==2264== searching for pointers to 1 not-freed blocks. ==2264== checked 3490188 bytes. ==2264== ==2264== 1280 bytes in 1 blocks are still reachable in loss record 1 of 1 ==2264== at 0x4014D4C8: malloc (in /usr/local/lib/valgrind/valgrind.so) ==2264== by 0x4021B96F: __default_alloc_template<true, 0>::chunk_alloc(unsigned int, int &) (in /usr/lib/libstdc++-2-libc6.1-1-2.9.0.so) ==2264== by 0x4021BA28: __default_alloc_template<true, 0>::refill(unsigned int) (in /usr/lib/libstdc++-2-libc6.1-1-2.9.0.so) ==2264== by 0x402140F2: basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0> >::replace(unsigned int, unsigned int, char const *, unsigned int) (in /usr/lib/libstdc++-2-libc6.1-1-2.9.0.so) ==2264== by 0x402169B7: basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0> >::basic_string(char const *) (in /usr/lib/libstdc++-2-libc6.1-1-2.9.0.so) ==2264== by 0x804A1D4: main (str_test.cpp:19) ==2264== by 0x402729CA: __libc_start_main (in /lib/libc-2.1.3.so) ==2264== by 0x804A130: ??? (/usr/include/g++-2/stl_alloc.h:533) ==2264== ==2264== LEAK SUMMARY: ==2264== definitely lost: 0 bytes in 0 blocks. ==2264== possibly lost: 0 bytes in 0 blocks. ==2264== still reachable: 1280 bytes in 1 blocks. ==2264== suppressed: 0 bytes in 0 blocks. ------------------ HJ |