Lesson 48 of 50
cMemory Debugging with Valgrind
10 mins
Course progress96%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 48 of 50
c10 mins
Keep these ideas in mind as you work through the lesson.
Valgrind detects memory leaks, invalid reads/writes, and use‑after‑free.
Typical usage:
valgrind --leak-check=full ./myprog arg1 arg2
Output includes:
int main(void) {
int *p = malloc(10 * sizeof *p);
p[0] = 42; // good
// forgot free(p);
return 0;
}
-g to get meaningful line numbers.--track-origins=yes to pinpoint uninitialised values.