
=17725= ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) =17725= For counts of detected and suppressed errors, rerun with: -v =17725= Rerun with -leak-check=full to see details of leaked memory =17725= still reachable: 72,704 bytes in 1 blocks =17725= possibly lost: 0 bytes in 0 blocks

=17725= indirectly lost: 0 bytes in 0 blocks =17725= definitely lost: 4 bytes in 1 blocks =17725= total heap usage: 2 allocs, 0 frees, 72,708 bytes allocated =17725= in use at exit: 72,708 bytes in 2 blocks =17725= Using Valgrind-3.10.1 and LibVEX rerun with -h for copyright info =17725= Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. The output looks something like this: =17725= Memcheck, a memory error detector As such, this is another case where simple examples prove the most instructive.
#VALGRIND MEMCHECK IN USE CODE#
Many programs cause a significant number of what we might call "false positives" being mistaken identification of something that's not a leak, or a memory leak in code we can't change (libraries, for example), or sometimes memory leaks that we just don't care about (it's not uncommon for a program to allocate memory once and just not bother to deallocate it when the process finishes, the memory will all be reclaimed anyway, so the programmer simply leaves it). What's less helpful is that this leads to a significant loss of speed having the program run at a few percent of normal speed isn't uncommon. This means that Valgrind can run on any executable without the need for any change in how that executable is built (although I suggest you build it with debug symbols added - note that this is not necessarily the same a a "debug build"), which is very helpful. Valgrind then executes that program under a "synthetic CPU" all the code being run is instrumented. The user executes Valgrind, providing the name of the executable of interest as a parameter. Being smart with your data layout and access can have phenomenal results. Having to fetch data from the slow memory is a "cache miss", and it takes a lot longer than fetching the data from the fast memory (the "cache").

Small amounts of fast memory, large amounts of slow memory, and sometimes layers inbetween.

Valgrind is a suite of simple, command-line tools (if you run valgrind without specifying which tool, you get the default memcheck tool) that enables you to identify a whole lot of things, of which the following are especially interesting to us in terms of performance:
