Questions tagged [valgrind]

Valgrind is a dynamic analysis tool for Linux, FreeBSD, macOS, Android, and Solaris systems. It can be used for execution and data profiling as well as for finding memory leaks, race conditions, and threading errors.

Valgrind is an open source instrumentation framework for building dynamic analysis tools. It was originally developed on Linux and has since been ported to other UNIX-like systems. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tools.

Valgrind works by effectively running your code in a virtual machine where extra instrumentation is available to monitor the behavior of your code in detail.

When instrumenting your code you should compile with debug symbols, like -g2 or -g3; and you should lower optimizations, like -O0 or -O1. Higher optimizations sometimes produce false positives. Also see The Valgrind Quick Start Guide.

Available GUIs frontends:

  • valkyrie
  • KDevelop lets you use Valgrind as a plugin
  • Eclipse has a GUI plugin to integrate Valgrind into its C++ Development Tools
  • Qt Creator can use memcheck and callgrind.

There are several tools for visualizing the Valgrind output

4117 questions
21
votes
9 answers

Unable to build and install Valgrind on macOS High Sierra

I cannot install Valgrind on macOS High Sierra. It's not available through brew. I've tried with 3.10. After make install, I get this message: configure: error: Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x and 14.x (Mac OS X…
Alexander Kleinhans
  • 5,950
  • 10
  • 55
  • 111
21
votes
2 answers

How to run valgrind with basic c example?

Installation: bzip2 -d valgrind-3.10.1.tar.bz2 tar -xf valgrind-3.10.1.tar then: ./configure make make install or simplier sudo apt-get install valgrind How to run valgrind on that simple program example1.c #include int main() { …
andrew
  • 3,083
  • 4
  • 24
  • 29
21
votes
1 answer

Open perf.data in Kcachegrind

I read somewhere that it is possible to convert perf.data (output from linux perf record profiling tool) to a format that kcachegrind can parse/plot, however I didn't find an application capable of doing this convertion and neither does kcachegrind…
JohnTortugo
  • 6,356
  • 7
  • 36
  • 69
21
votes
3 answers

install valgrind, Fatal error at startup

I am installing Valgrind but encounter some problems. The info of my platform: Linux xx-ThinkPad-X61 3.2.0-39-generic-pae #62-Ubuntu SMP Wed Feb 27 22:25:11 UTC 2013 i686 i686 i386 GNU/Linux I follows the installation instruction of the README file…
ulyssis2
  • 1,165
  • 3
  • 10
  • 24
21
votes
1 answer

Suppress Valgrind warnings from iOS SDK

I followed this approach to run Valgrind on an iOS app. Unfortunately the warnings pertaining to the iOS SDK make it almost impossible to find any warnings related to my app. Is there a list of iOS suppressions for Valgrind so I don't have to…
moinudin
  • 134,091
  • 45
  • 190
  • 216
21
votes
4 answers

How can I monitor memory usage of php in linux?

I have used valgrinds massif tool to monitor memory usage in the past. Does anyone know how to capture memory use of php processes that are spawned on a linux lighttpd server? I have found that Valgrind can not attach to a prerunning process (and I…
DEzra
  • 2,978
  • 5
  • 31
  • 50
20
votes
1 answer

What do the suppressed leaks mean in Valgrind?

I have developed a pure-C implementation of FIFO lists (queues) in files fifo.h and fifo.c, and have written a test programme testfifo.c which I compile to ./bin/testfifo. The node structure is defined in list.h. I run my programme through Valgrind…
Genba
  • 854
  • 2
  • 10
  • 19
20
votes
3 answers

Are there known false positives issues with Valgrind?

Are there any known false positives with Valgrind? I get a 'Conditional jump or move depends on uninitialised value(s)' with the fmemopen function, writing in C and compiling with GCC. Can I be sure it's real? EDIT: Are there known issues that are…
Liran Orevi
  • 4,755
  • 7
  • 47
  • 64
20
votes
3 answers

Valgrind on MIPS Reports no Heap Usage

I'm using valgrind (v3.10.0) to hunt down a memory leak in a complex application (a heavily modified build of net-snmp) that is being built as part of a bigger software suite. I am sure there is a leak (the memory footprint of the application grows…
Woodrow Barlow
  • 8,477
  • 3
  • 48
  • 86
20
votes
7 answers

Is it normal that running python under valgrind shows many errors with memory?

I've tried to debug memory crash in my Python C extension and tried to run script under valgrind. I found there is too much "noise" in the valgrind output, even if I've ran simple command as: valgrind python -c "" Valgrind output full of repeated…
bialix
  • 20,053
  • 8
  • 46
  • 63
20
votes
5 answers

multiple threads writing to std::cout or std::cerr

I have OpenMP threads that write to the console via cout and cerr. This of course is not safe, since output can be interleaved. I could do something like #pragma omp critical(cerr) { cerr << "my variable: " << variable << endl; } It would be…
Wolfgang
  • 1,408
  • 2
  • 15
  • 20
19
votes
4 answers

Is there a way to install Valgrind on Catalina?

Is there a way to install Valgrind on Catalina and have it run properly? If so, I would very much appreciate a step-by-step process. I tried installing Valgrind with https://github.com/sowson/valgrind but when I tested out helloWorld.cpp on the…
John Park
  • 335
  • 5
  • 23
19
votes
3 answers

Quit valgrind cleanly when debugging with gdb

I am debugging a program using valgrind and gdb. However I terminate those debugging sessions in a barbaric way… Is it really how it is meant to be done ? Setting up the debugging session Following the instructions from the official valgrind website…
Gael Lorieul
  • 3,006
  • 4
  • 25
  • 50
19
votes
3 answers

How to suppress valgrind warnings by the origin of the uninitialized values?

Valgrind will tell you the origin of the uninitialized values with the track-origins=yes option. I tried to suppress these warnings but the problem is that data based on uninitialized values can propagate everywhere, causing warnings elsewhere too.…
Calmarius
  • 18,570
  • 18
  • 110
  • 157
19
votes
3 answers

Memory leak reported by valgrind in dlopen?

I've been debugging some app lately with valgrind, and I'm getting very weird reports from dlopen. ==1987== 32 bytes in 1 blocks are still reachable in loss record 1 of 2 ==1987== at 0x4C24477: calloc (vg_replace_malloc.c:418) ==1987== by…
Anteru
  • 19,042
  • 12
  • 77
  • 121