Memory Leaks Check with Valgrind

Version 9

    What is Valgrind ?

    Valgrind is an  instrumentation framework for building dynamic analysis tools.  There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail.  You can also use Valgrind to build new tools.


    Get the current release from

    download valgrind-3.5.0.tar.bz2

    tar jxvf valgrind-3.5.0

    cd valgrind-3.5.0



    su -c 'make install' (valgrind execute will install in /usr/local/bin)


    Running valgrind to detect memory leak

    Valgrind is now integrated with our build on Linux and as such it will execute during a standard run of the tests in maven. If you want to trigger the maven run of the tests under valgrind on Linux:

    2. mvn cpp:test
    3. The output will be located at <BLACKTIE_SRC_DIR>/<PROJECT_NAME>/target/cpp-test-classes/<PROJECT_NAME>-valgrind.log


    Results of valgrind

    The details are in the Memcheck section of the user manual.

    In short:

    • "definitely lost" means your program is leaking memory --         fix it!

    • "possibly lost" means your program is probably leaking         memory, unless you're doing funny things with pointers.

    • "still reachable" means your program is probably ok -- it         didn't free some memory it could have.  This is quite common and         often reasonable.  Don't use         --show-reachable=yes if you don't want to see         these reports.

    • "suppressed" means that a leak error has been suppressed.         There are some suppressions in the default suppression files.         You can ignore suppressed errors.