Home

Memcheck

Memcheck is a memory error detector within the Valgrind instrumentation framework. It checks programs for memory management problems in C, C++, and related languages by executing the program under Valgrind’s dynamic instrumentation. Memcheck can detect uninitialized reads, reads and writes to freed or unallocated memory, buffer overruns, and memory leaks, among other errors.

How Memcheck works: It uses a shadow memory model to track the state of every byte of

Usage: Typical workflow is to compile with debugging symbols and run under Valgrind, for example: valgrind --tool=memcheck

Limitations and scope: Memcheck detects many common memory errors but is not a general debugger and can

History and relation: Memcheck is the most widely used tool in the Valgrind suite, developed as part

the
program’s
memory.
As
the
program
runs,
Memcheck
records
allocations
and
frees
and
checks
each
memory
access
against
the
shadow
state.
When
an
error
is
detected,
Memcheck
reports
the
location
with
stack
traces
if
symbols
are
available.
It
can
classify
memory
leaks
into
categories
such
as
definitely
lost,
indirectly
lost,
possibly
lost,
and
still
reachable,
and
can
track
origins
for
uninitialized
values
with
appropriate
options.
--leak-check=full
--show-leak-kinds=all
./program
[args].
Optional
flags
include
--track-origins=yes,
--suppressions=,
and
--error-exitcode.
Output
consists
of
error
messages
detailing
each
issue
and
a
summary
of
leaks
at
program
exit,
aiding
developers
in
locating
and
fixing
problems.
miss
some
issues.
It
imposes
substantial
runtime
overhead,
making
it
unsuitable
for
production
use.
It
may
report
false
positives
in
some
scenarios
and
usually
requires
debugging
information
to
provide
meaningful
traces.
of
the
Valgrind
project
to
help
developers
identify
memory
management
bugs
in
software.