Valgrind

The Linux Tools Project Valgrind plugin aims to provide simple and effective profiling for the C/C Development Tools. There is an abundance of Valgrind functionality to expose in Eclipse. Valgrind itself is very component based and this relates well to Eclipse plugins. Valgrind is here to help! You run a program under valgrind to enable extensive checking of memory allocations and accesses and it provides a report with detailed information about the context and circumstances of each error. Memory errors versus memory leaks Memory issues come in two flavors: memory errors and memory leaks.

Valgrind is a developer tool for C++ developers used to find memory issues including C++ memory leak detection. Valgrind uses instrumentation to collect information about allocated and freed memory to gather complete information about memory blocks.

Many developers ask how to use Valgrind on Windows and Visual Studio. Valgrind heavy relies on Linux internals, that’s why Valgrind does not support Windows.

Fortunately, there is a Valgrind alternative for Windows, called Deleaker. It is a memory profiler tool for Windows. While Valgrind uses instrumentation that makes the code slower about 10x times, Deleaker uses hooks and does not modify code of a program: code execution speed remains almost the same. Deleaker doesn’t require a program to be rebuilt. All what Deleaker needs is a debug information to locate source of leaks.

Also Deleaker detects Windows specific leaks such as GDI leaks, leaks of handles.

Deleaker can work as a standalone application and as an extension for Visual Studio. The standalone version is suitable for memory leaks profiling on a client machine when the installation of Visual Studio is not allowed. If your favourite IDE is Qt Creator or C++ Builder, it is worth mentioning that Deleaker integrates with them as well.

With Deleaker extension for Visual Studio, a developer checks code for memory leaks, identifying exact leaking places quite quickly. Deleaker assists a developer, showing list of allocated memory blocks with their call stacks and other information including hit count, size, module path and others.

Let’s look at how it works. Create new console application and add a simple leak:

Before starting debugging, ensure that Deleaker is enabled:

Start debugging. The application allocates memory and exits. Once the debugging stopped, Deleaker takes a snapshot and shows a report. To navigate to the source of a leak, just right-click and select Show Source Code:

Deleaker can compare snapshots to find some recurring leaks. Also a developer can export snapshots to review them later.

Deleaker comes with a command line tool, DeleakerConsole.exe, that can be used to integrate memory leaks checking into continuous integration process to ensure that an application does not leak. DeleakerConsole.exe prepares memory leaks reports in XML format that can be analyzed.

Valgrind

If you are looking for an alternative of Valgrind, try Deleaker. It is a C++ memory leak detection tool for Windows that is fast, supports both 32-bit and 64-bit code, and integrates with all major IDE including Visual Studio, Qt Creator and RAD Studio.

This page is part of the debugging series — pages with debugging details for a variety of Ubuntu packages.

Valgrind is a suite of tools for debugging and profiling programs. There are three tools: a memory error detector, a time profiler, and a space profiler.

Valgrind

For debugging purposes, the memory error detector is a handy tool.

The most important of these is the memory error detector, which tracks the usage of every single bit in a program, and warns if there's something suspicious. Valgrind can detect if memory is used before it has a value, memory is leaked, or memory is used twice.

Valgrind Download

This makes it ideal for tracking down segmentation faults, bus errors, and general memory leaks.

Please ensure you have packages with debug symbols installed. You can do this by following the instructions at DebuggingProgramCrash.

  1. Make sure Valgrind is installed.

  2. Remove any old Valgrind logs:

  3. Start the program under control of memcheck:

  1. N.B. valgrind can't solve paths, so you should feed it the full program path, to get it: $(which <program>)

  2. The program will start. It may take a while; this is normal, because Valgrind must perform extensive checking to detect memory errors.
  3. Perform any actions necessary to reproduce the crash.
  4. Package up the log files (no need if there is only one):

  5. Attach the complete output from Valgrind, contained in valgrind-logs-<program>.tar.gz, in your bug report.

Valgrind FAQ

Debugging With Valgrind

CategoryBugSquadCategoryDebugging

  • Spanish

Valgrind Windows

Valgrind (last edited 2013-01-03 17:20:38 by brian-murray)