Valgrind – A brief summary

My project's page

Valgrind – A brief summary

15 March 2017 Programming tools 0 logo
Hello everyone, in this post we’ll take a quick look at Valgrind to understand what is it. In future articles we’ll analyze in detail the different tools and we’ll see how to use them to the fullest.
Valgrind is a multipurpose tool, a Swiss boxcutter for programmers.
This helps us in many different situations: from profiling to debugging of Linux memory. Initially it was available for x86, version 3 it is for AMD64 and other architectures. Valgrind allows us to run our program in its environment that controls memory usage, such as calls to malloc and free (or new and delete in the case of C ++). If you write out the end of an array, you forget to free a pointer or other errors or oversights of this type, Valgrind is able to detect it. Since these are quite common problems, we will see how to use Valgrind to find these types of memory problems, although Valgrind is a much more powerful tool and it can do much more.

The command to run Valgrind in Linux terminal is:

tool_name is the name of the tool to use and program_path is the path of the program to run with Valgrind.
The most known and used tools are:

  • Memcheck
  • Addrcheck
  • Massif
  • Cachegrind
  • Callgrind
  • Helgrind

Memcheck is a memory error detector. It helps programmers make programs, particularly those written in C and C++, more robust and correct.

Addrcheck is a simplified and lightened version of MemCheck. It is identical to MemCheck in every way, except for one important detail: AddrCheck don’t check Undefined values. This means Addrcheck is faster than MemCheck and uses fewer resources (in terms of memory and processor).

Massif is a heap profiler. It allows us to analyze the state of the heap and then allows us to write programs that use less memory.

Cachegrind is a cache and branch-prediction profiler. It helps you make your programs run faster.

Callgrind is a cache profiler that generates call-graph. It has some overlap with Cachegrind, but also gathers some information that Cachegrind does not.

Helgrind is a thread errors detector. It helps us to make more correct multi-threaded programs.


Leave a Reply

Your email address will not be published. Required fields are marked *