This guide explains how to detect memory leaks and allocation errors in the cmenu project using various tools.
No additional installation needed - macOS has built-in tools.
# Ubuntu/Debian
sudo apt-get install valgrind
# Arch Linux
sudo pacman -S valgrindRuns the program with AddressSanitizer:
- Detects memory leaks, buffer overflows, use-after-free
- Very fast and accurate
- Built into Clang/GCC
Runs AddressSanitizer with sample input for testing.
Runs the program with macOS's built-in leaks tool:
- Detects memory leaks at program exit
- No performance impact
- macOS only
Runs a comprehensive Valgrind analysis with:
- Full leak checking
- Origin tracking
- Verbose output
- Results saved to
valgrind-out.txt
Runs a quick Valgrind check with:
- Full leak checking
- Suppressed system library false positives
- Console output only
Runs Valgrind focusing on memory errors:
- Origin tracking for debugging
- No leak checking (faster)
- Good for finding use-after-free and invalid memory access
# Quick test with sample input
make asan-test# Test with built-in leaks tool
make leaks-test# Quick test with sample input
make valgrind-test| Tool | Platform | Speed | Accuracy | Setup |
|---|---|---|---|---|
| AddressSanitizer | All | Fast | High | Easy |
| Leaks | macOS | Very Fast | Medium | None |
| Valgrind | Linux | Slow | High | Easy |