High Performance Computing: ICC\'s High Performance Computing: Code Development

Valgrind Memcheck Tool

Contents

  1. Introduction
  2. Platforms and Locations
  3. Quick Start
  4. Troubleshooting
  5. Documentation and References

Introduction

Memcheck is part the Valgrind suite of simulation-based debugging and profiling tools. Memcheck detects memory-management problems, and is aimed primarily at C and C++ programs. When a program is run under Memcheck's supervision, all reads and writes of memory are checked, and calls to malloc/new/free/delete are intercepted. As a result, Memcheck can detect if your program:

  • Accesses memory it shouldn't (areas not yet allocated, areas that have been freed, areas past the end of heap blocks, inaccessible areas of the stack).
  • Uses uninitialised values in dangerous ways.
  • Leaks memory.
  • Does bad frees of heap blocks (double frees, mismatched frees).
  • Passes overlapping source and destination memory blocks to memcpy() and related functions.

Memcheck reports these errors as soon as they occur, giving the source line number at which it occurred, and also a stack trace of the functions called to reach that line. Memcheck tracks addressability at the byte-level, and initialization of values at the bit-level. As a result, it can detect the use of single uninitialized bits, and does not report spurious errors on bitfield operations. Memcheck runs programs about 10-30x slower than normal.

Platforms and Locations

    Platform Location Notes
    x86_64 Linux /usr/local/bin/memcheck* Multiple versions are available. Use Dotkit to load.
    BG/Q /usr/local/tools/valgrind/branch38bgq-2014May21 See BG/Q usage notes in "Quick Start" section below.

Quick Start

See the LC document "Using Valgrind's Memcheck Tool to Find Memory Errors and Leaks in MPI and Serial Applications on Linux" located at https://computing.llnl.gov/code/memcheck/.

BG/Q Usage Notes:

LC's current version of Memcheck for BG/Q is limited to statically linked executables. Additionally, you must build your application using LC's memcheck_link utility. For example:

memcheck_link mpixlc -g -o testmpi_mc testmpi.c
Following this, memcheck usage is similar to that described in the Memcheck document linked above.

Troubleshooting

  • Please contact John Gyllenhaal (via e-mail to gyllen@llnl.gov or telephone 925-424-5485)
  • Problems may also be reported to the LC Hotline.

Documentation and References

Top