Lab 7: Valgrind - Memory debugging tool | CMSC 240 Software Systems Development - Fall 2024

Lab 7: Valgrind - Memory debugging tool

Instructions

Objective

In this lab, you will learn to use Valgrind, a very handy memory debugging tool. Using Valgrind, you can find many memory management errors in your programs, include memory leaks. So why should you use Valgrind?

Valgrind will save you hours of debugging time.

particularly when using dynamically allocated memory. When using dynamic memory management in C++, you should make frequent use of Valgrind.

Now let’s walk through some intentionally buggy example programs, demonstrating the use of Valgrind to find the bugs and highlighting common memory mistakes along the way.

Program 1

Program 2

Program 3

Programs 4, 5

Program 6

Acknowledgements

This lab is based on the Valgrind lab created by Prof. Doug Szajda at UR and Prof. Will Jones at Clemson University.