Module 14 · Dynamic Memory
Leaks, Double Free, and the Tools That Find Them
Free with an accountReading
Kenji's server answers every request correctly, and keeps 4 KB from each one forever. At a thousand requests a minute, that is 240,000 KB an hour, almost the 256,000 KB a Playground run may touch. After a day it is over 5 GB.
Checking what this lesson needs for you…
What is inside Leaks, Double Free, and the Tools That Find Them
- A leak: a block nobody can reach
- Two ways to lose a block
- Every block has one owner
- A double free: glibc stops the program
- A use after free: wrong numbers, and no crash
- Freeing what malloc never handed out
- AddressSanitizer and LeakSanitizer
- The analyzer: GCC checks the paths without running them
- Valgrind, on your own Linux machine
- Why the Playground cannot name a leak
- The leak checklist