Leaks (Mac)

Leaks is a tool available on Mac computers that performs similar kinds of memory checking to Valgrind.

Here are the main differences:

Before running leaks, type the following into the terminal (need to do this only once per session - do it each time you open a new terminal to check for memory issues):

export MallocStackLogging=1

That will preserve information about when you allocate memory (malloc).

To run leaks, you will always do:

leaks --atExit -- ./YOUR_PROGRAM_NAME

To build your code, you can type either g++ (as shown in valgrind instructions) or clang++ (as shown in video below). Whichever you do, make sure to always include -g in the compile recipe.

A Video Demonstration

This video does a good job of demonstrating Leaks in Action. Do make sure to still check out the materials here on using valgrind which talk about the kinds of things to look for in the error report.