Tag Archives: valgrind

Valgrind is awesome !

Over the past few weeks that I’ve been working on my GSoC, one fantastic tool has proven to be a lifesaver of sorts, or at least a very quick way to trace segmentation faults and memory leaks : Valgrind.

Valgrind is a full suite of tools for testing, debugging and profiling programs, but the only tool from this suite that I’ve used is Memcheck. As the name suggests, memcheck pinpoints the exact line numbers in source files where invalid read/writes are taking place or uninitialized values are being used, and also reports memory leaks in a similar fashion.

You can have a look at all of memcheck’s capabilities here.

To test a program with valgrind, you simply have to run :

valgrind ./myprogram

This will return a list of invalid read/writes and other instances of misuse of pointers.

To additionally check for memory leaks, use

valgrind --leak-check=yes ./myprogram

Note that when testing a program with valgrind, the program may run slower than usual.

Advertisements
Tagged ,