valgrind_test


valgrind_test a Fortran77 code which uses valgrind(), a suite of programs which includes a memory leak detector.

The simplest way to use VALGRIND on a program that is suspected of having memory leaks is to compile with the "-g" option, and then issue the VALGRIND command followed by the normal execution command:

        gfortran -g myprog.f
        mv a.out myprog
        valgrind ./myprog
      

On a Macintosh, it is necessary to include a particular switch that generates the necessary symbol tables in order that VALGRIND can report line numbers.

        valgrind --dsymutil=yes myprog
      

Essentially, VALGRIND runs the program, but constantly watches to detect illegal memory references, and prints messages when these are spotted.

Licensing:

The information on this web page is distributed under the MIT license.

Languages:

valgrind_test examples are available in a C version and a C++ version and a Fortran77 version. a Fortran90 version.

Reference:

  1. Julian Seward, et al,
    Valgrind Documentation.

Examples and Tests:

TEST01 is an example in which 11 elements of the Fibonacci sequence are stored in a vector allocated only for 10 elements:

TEST02 is an example in which some uninitialized data is accessed.


Last revised on 17 April 2021.