Date: Fri, 16 Mar 2012 13:23:48 +0200 From: "Ina J." <inarvaj@gmail.com> To: freebsd-stable@FreeBSD.org Subject: FreeBSD 9.0: Valgrind leaks memory Message-ID: <CAPKAR4KGO31ZyJuZi0x=iF=UnUVfxXGWWnOLw7n9Nd7nhXhc3Q@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hi, I tried to find a thread about this, but I didn't and in this thread<http://forums.freebsd.org/showthread.php?t=16468>trasz suggested to send message to the mailing list. I've been developing program for Linux under Ubuntu 10.04. I want to get the code running under my FreeBSD 9.0-RELEASE server. The code compiles without problems, but Valgrind doesn't work the same way as on my Ubuntu. I made an example code, which produces a memory leak with Valgrind. The code is as follows: ### C O D E ### #include <iostream> int main() { std::cout << "Valgrind leaks memory" << std::endl; return 0; } I compile it simply with command: g++ test.cc And then run it in valgrind: valgrind --show-reachable=yes --tool=memcheck --db-attach=yes --leak-check=full --track-origins=yes ./a.out And Valgrind outputs this: ### V AL G R I N D O U T P U T ### ==39783== Memcheck, a memory error detector ==39783== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. ==39783== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info ==39783== Command: ./a.out ==39783== Valgrind leaks memory ==39783== ==39783== HEAP SUMMARY: ==39783== in use at exit: 4,096 bytes in 1 blocks ==39783== total heap usage: 1 allocs, 0 frees, 4,096 bytes allocated ==39783== ==39783== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 1 ==39783== at 0x5BF98: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-x86-freebsd.so) ==39783== by 0x26B503: ??? (in /lib/libc.so.7) ==39783== by 0x26B3C4: ??? (in /lib/libc.so.7) ==39783== by 0x26AF12: ??? (in /lib/libc.so.7) ==39783== by 0x26AAB4: fwrite (in /lib/libc.so.7) ==39783== by 0xA1135: ??? (in /usr/lib/libstdc++.so.6) ==39783== by 0xDC3C7: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int) (in /usr/lib/libstdc++.so.6) ==39783== by 0xDC5DB: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (in /usr/lib/libstdc++.so.6) ==39783== by 0x80488C4: main (in /usr/home/ina/test/a.out) ==39783== ==39783== LEAK SUMMARY: ==39783== definitely lost: 0 bytes in 0 blocks ==39783== indirectly lost: 0 bytes in 0 blocks ==39783== possibly lost: 0 bytes in 0 blocks ==39783== still reachable: 4,096 bytes in 1 blocks ==39783== suppressed: 0 bytes in 0 blocks ==39783== ==39783== For counts of detected and suppressed errors, rerun with: -v ==39783== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) In my Ubuntu, Valgrind detects no memory leaks. Although, those reported leaks are just reachable bytes, but there shouldn't be any of them. On my Ubuntu g++ and Valgrind versions are as follows: g++ (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3 valgrind-3.6.0.SVN-Debian And on FreeBSD: g++ (GCC) 4.2.1 20070831 patched [FreeBSD] valgrind-3.6.1 With my actual code, Valgrind reports a lot more memory leaks and also those mentioned on the thread I linked, but sample code is enough to produce errors which shouldn't exist. -Ina
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPKAR4KGO31ZyJuZi0x=iF=UnUVfxXGWWnOLw7n9Nd7nhXhc3Q>