Tutorial by Examples

valgrind ./my-program arg1 arg2 < test-input This will run your program and produce a report of any allocations and de-allocations it did. It will also warn you about common errors like using uninitialized memory, dereferencing pointers to strange places, writing off the end of blocks allocate...
You can also turn on more tests, such as: valgrind -q --tool=memcheck --leak-check=yes ./my-program arg1 arg2 < test-input See valgrind --help for more information about the (many) options, or look at the documentation at http://valgrind.org/ for detailed information about what the output mea...
Here is a program that calls malloc but not free: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char *s; s = malloc(26); // the culprint return 0; } With no extra arguments, valgrind will not look for this error. But if we turn on...
Valgrind provides you with the lines at which the error occurred at the end of each line in the format (file.c:line_no). Errors in valgrind are summarised in the following way: ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) The most common errors include: Illegal read/write er...

Page 1 of 1