Valgrind is a GPL software used for memory debugging and code analysis in LINUX systems. It can monitor memory usage in code, such as malloc and free in c, new and delete in c ++.
Valgrind can be used to check bugs in memory and threads.
Valgrind contains many tools, such as memcheck, cachegrind, helgrind, callgrind, and massif.
Memcheck mainly checks the following errors
1. Use uninitialized memory
2. Use the released memory
3. Use memory space that exceeds malloc allocation
4. Illegal stack access
5. Whether the applied space has been released
6. Does malloc/free match with new/delete?
7. src/dst overlapping
Functions of cachegrind
It simulates the cache of the CPU and can accurately point out the memory loss and hit of the program. If needed, it can also provide us with the number of cache losses.
Helgrind analyzes problems in multiple threads, such as competition and locking.
Massif stack Analyzer
It can measure the memory used by the program in the stack area. It tells us the heap management block, stack size, and heap block size.
Use of valgrind
Related options for Memcheck:
-Leak-check = no | summary | what is the leak details required for full? [Summary]
-Leak-resolution = low | med | high how much bt merging in leak check [low]
-Show-reachable = no | yes show reachable blocks in leak check? [No]
Author: "dancer blog"