[VIDEO PLAYBACK] DAVID MALAN: So what else can go wrong now that we have the ability to touch, correctly or incorrectly, any memory that we add-- [END PLAYBACK] DAVID MALAN: So at this point in the term, too, it's a nice opportunity to dive into another topic that you wouldn't typically see, I think, at this point in the semester, or let alone an intro class, which is a discussion of memory leaks, right? Because this language, C, is not giving us that feature, at least in the general case, so we have added it to the CS50 library. DOUG LLOYD: Memory leaks are actually kind of a tricky topic to teach, because in the context of CS50, in the programs that we're writing, we're not really going to notice a memory leak for us. DAVID MALAN: Right, no. But I think it's important for correctness for students to also realize the causal relationship between them allocating memory and the program itself ultimately leaking if they don't actually give it back. And what's nice too is that in Valgrind, even though its syntax is not nearly as accessible as would be ideal and its output even more so, it's a very deterministic tool that can tell students whether or not their code is leaking, and better still, if they are touching memory at some point that they shouldn't be, even it's not just by luck inducing an actual site fault for them. DOUG LLOYD: Right, and this year, we're actually able again to teach Valgrind earlier because we revamped the CS50 library to have garbage collection, where previously Valgrind would throw sort of false errors out because get string technically leaked memory when you used it. DAVID MALAN: And now, you don't have to worry about that. And, as we discussed when we looked again at help 50, the new command line tool with which students can translate a program's output to more human friendly messages, Valgrind was kind of top of our list for that. I mean, the output of Valgrind is just so unnecessarily complex. Like, I don't know why the authors decided to just repeat the process ID of the thing again and again and again and again all along the left-hand side. It's not all that useful, and it's certainly distracting except when maybe you might have multiple processes interacting and you want to see them both. But in our case, it's just it's just a distraction. DOUG LLOYD: Yeah, it's just a distraction. DAVID MALAN: And so, help 50 now, thankfully, will translate those messages for students in a way that I don't think is to their detriment in terms of understanding, because indeed, in reality, they're not going to use Valgrind all that likely beyond the scope of CS50 if they're generally programming in other languages. But they're still seeing the output, and then we're helping them translate it, much like a TF or CA would if he or she came over to you to explain.