# Valgrind debugging procedures Source: [https://docs.qualcomm.com/doc/80-88500-3/topic/99_Valgrind_debugging_procedures_.html](https://docs.qualcomm.com/doc/80-88500-3/topic/99_Valgrind_debugging_procedures_.html) Valgrind is a programming tool for memory debugging, memory leak detection, and profiling. The Valgrind binary is built as part of the QRB5165 device, by default. The Valgrind tool suite provides a number of debugging and profiling tools (for example `Memcheck`) that help to make your programs faster and more correct. It can detect many memory-related errors that are common in C and C++ programs and that can lead to crashes and unpredictable behavior. Valgrind can detect the following memory-related problems: - Use of uninitialized memory - Reading/writing memory after it has been freed - Reading/writing off the end of malloced blocks (overflow/underflow) - Memory leaks - Mismatched use of `malloc/new/new[]` vs. `free/delete/delete[]` - Doubly freed memory The following command is used to run Valgrind: $ valgrind Copy to clipboard ## Valgrind command flags - `--tool=memcheck`: Checks for uninitialized memory or accessing a freed memory. - `--leak-check=full`: Shows each individual leak in detail. - ` --show-leak-kinds=all`: Shows all definite, indirect, possible, reachable leak kinds in the full report. - `--track-origins=yes`: Favors useful output over speed. This parameter tracks the origins of uninitialized values, which could be useful for memory errors. Consider turning off if Valgrind is unacceptably slow. - ` --log-file`: Writes to a file. - **[Run Valgrind](https://docs.qualcomm.com/doc/80-88500-3/topic/100_Run_Valgrind.html)** **Parent Topic:** [Debug mechanisms](https://docs.qualcomm.com/doc/80-88500-3/topic/77_Debugging_procedures.html) Last Published: Sep 26, 2023 [Previous Topic Measure DDR clock (DDR status)](https://docs.qualcomm.com/bundle/publicresource/80-88500-3/topics/98_Measure_DDR_clock__DDR_status__.md) [Next Topic Run Valgrind](https://docs.qualcomm.com/bundle/publicresource/80-88500-3/topics/100_Run_Valgrind.md)