Valgrind & Leaks

Valgrind is a tool for checking for memory issues in your code - spots where you leak memory or spots where you access invalid memory. Valgrind is only supported on Linux, which means you are a Windows or Mac you will need access to a Linux machine. (Or a Mac you can also chose to run an alternate tool called Leaks.)

Start by choosing one of these setup options. After you have picked how to use Valgrind, you can continue on to the Using Valgrind instructions.

Windows

Pick one of these two options (#1 is recommended):

  1. Install Windows Subsystem for Linux and run a virtual Linux machine on your computer. This may take a little more time to install initially, but will be faster to make use of when you want to go test a program.

  2. Use rsync to upload your code to the CS Student Server where valgrind is already installed. If you choose this method, there will be the extra steps of logging into the remote machine every time you want to test out a new project and of uploading your code to the server each time you modify it and want to retest it. See the CS Student Server instructions for how to connect to the server and upload files to it.

    If you plan on using this method, email your instructor to make sure they set up an account for you.

Mac

Pick one of these two options (#1 is recommended):

  1. Use the leaks command instead of Valgrind. The syntax will be very slightly different. And the report you get has much of the same information that Valgrind would provide, but the formatting will be slightly different. But this will be the quickest way to get memory reports.

  2. Use rsync to upload your code to the CS Student Server where valgrind is already installed. If you chose this method, there will be the extra steps of logging into the remote machine every time you want to test out a new project and of uploading your code to the server each time you modify it and want to retest it. See the CS Student Server instructions for how to connect to the server and upload files to it.

    If you plan on using this method, email your instructor to make sure they set up an account for you.

Linux

Use your package manager to install valgrind (apt install valgrind).