Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2017 - January 2018

17.5.2.  Valgrind, memory leak detection


  • Valgrind quick start guide (sections 1,2,3,4,5 and 6).

  • Folder with name Valgrind_first and file testing_valgrind.c in the shared folder Subversion. There is a local copy here

Work Plan

We are going to use the tool Valgrind to detect memory leaks. Valgrind is in fact a framework with a set of tools such as Memcheck (the one we are going to focus on), which allows you to execute a C program and see if any line of your code produces a memory leak or any other memory-related error.

  1. Read the quick start guide offered as resource.

  2. Open a command terminal and compile and execute the program testing_valgrind.c that you will find in the Valgrind_first folder in your shared space. Execute again the program using Valgrind and analyze the report bout the memory usage that is printed.

  3. Modify the program testing_valgrind.c such that when executing with Valgring, no error is shown. Upload the new version of the file to the repository with Subversion.