valgrind

Valgrind claims there is unfreed memory. Is this bad?

纵然是瞬间 提交于 2019-12-01 09:07:00
Valgrind gives me the following leak summary on my code. However, I have freed all malloc'ed memory. Is this a bad thing, or is this normal? My program is in c. ==3513== LEAK SUMMARY: ==3513== definitely lost: 0 bytes in 0 blocks. ==3513== possibly lost: 0 bytes in 0 blocks. ==3513== still reachable: 568 bytes in 1 blocks. ==3513== suppressed: 0 bytes in 0 blocks. The valgrind message still reachable: 568 bytes in 1 blocks. means that there was memory freed in your application which is still "reachable", which means that you still have a pointer to it somewhere. At shutdown, this probably

Valgrind claims there is unfreed memory. Is this bad?

若如初见. 提交于 2019-12-01 07:47:20
问题 Valgrind gives me the following leak summary on my code. However, I have freed all malloc'ed memory. Is this a bad thing, or is this normal? My program is in c. ==3513== LEAK SUMMARY: ==3513== definitely lost: 0 bytes in 0 blocks. ==3513== possibly lost: 0 bytes in 0 blocks. ==3513== still reachable: 568 bytes in 1 blocks. ==3513== suppressed: 0 bytes in 0 blocks. 回答1: The valgrind message still reachable: 568 bytes in 1 blocks. means that there was memory freed in your application which is

Kcachegrind/callgrind is inaccurate for dispatcher functions?

故事扮演 提交于 2019-12-01 06:32:14
I have a model code on which kcachegrind/callgrind reports strange results. It is kind of dispatcher function. The dispatcher is called from 4 places; each call says, which actual do_J function to run (so the first2 will call only do_1 and do_2 and so on) Source (this is a model of actual code) #define N 1000000 int a[N]; int do_1(int *a) { int i; for(i=0;i<N/4;i++) a[i]+=1; } int do_2(int *a) { int i; for(i=0;i<N/2;i++) a[i]+=2; } int do_3(int *a) { int i; for(i=0;i<N*3/4;i++) a[i]+=3; } int do_4(int *a) { int i; for(i=0;i<N;i++) a[i]+=4; } int dispatcher(int *a, int j) { if(j==1) do_1(a);

Why is Valgrind stating that my implementation of std::map<T, T> produces a memory leak?

こ雲淡風輕ζ 提交于 2019-12-01 05:59:28
问题 Valgrind is outputting the following: ==14446== 2,976 (176 direct, 2,800 indirect) bytes in 2 blocks are definitely lost in loss record 23 of 33 ==14446== at 0x4C2506C: operator new(unsigned long) (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so) ==14446== by 0x41C487: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned const, vimrid::imaging::ImageMatrixColumn> > >::allocate(unsigned long, void const*) (new_allocator.h:92) ==14446== by 0x41C4AB: std::_Rb_tree<unsigned,

Debug boost::thread application, high false positive rate

隐身守侯 提交于 2019-12-01 05:47:52
I have programmed a boost::thread application, where I might have some race conditions. I want to debug this program. Therefore I used the following valgrind tools: halgrind drd unfortunately they have a very false positive rate. So with the really simple program below valgrind --tool=drd complains about 94 errors, where no should be. So with my complex program I get about 15000 errors. So it is really hard to find the actual error. I could reproduce this behavior with the following boost libraries 1.46.0 and 1.47.0. And with valgrind 3.7.0 SVN and valgrind 3.8.0 SVN. The operating systems I

How do you get Valgrind to show line errors?

寵の児 提交于 2019-12-01 05:31:42
How do you get Valgrind to show exactly where an error occured? I compiled my program (on a Windows machine over a Linux terminal via PuTTy) adding the -g debug option. When I run Valgrind, I get the Leak and Heap summary, and I definitely have lost memory, but I never get information about where it happens (file name, line). Shouldn't Valgrind be telling me on what line after I allocate memory, it fails to deallocate later? ==15746== ==15746== HEAP SUMMARY: ==15746== in use at exit: 54 bytes in 6 blocks ==15746== total heap usage: 295 allocs, 289 frees, 11,029 bytes allocated ==15746== =

dump valgrind data

混江龙づ霸主 提交于 2019-12-01 05:16:57
I am using valgrind on a program which runs an infinite loop. As memcheck displays the memory leaks after the end of the program, but as my program has infinite loop it will never end. So is there any way i can forcefully dump the data from valgrind time to time. Thanks acm Have a look at the client requests feature of memcheck . You can probably use VALGRIND_DO_LEAK_CHECK or similar. EDIT : In response to the statement above that this doesn't work. Here is an example program which loops forever: #include <valgrind/memcheck.h> #include <unistd.h> #include <cstdlib> int main(int argc, char*

The valgrind reports error when printing allocated strings

那年仲夏 提交于 2019-12-01 05:10:54
The code is here: #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char* buf = malloc(3); strcpy(buf, "hi"); printf("%s\n", buf); free(buf); } It's compiled with: gcc a.c && valgrind ./a.out The error message is here: ==1421== Memcheck, a memory error detector ==1421== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. ==1421== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info ==1421== Command: ./a.out ==1421== ==1421== Invalid read of size 8 ==1421== at 0x4EA96C1: ??? (in /lib/libc-2.14.1.so) ==1421== by 0x4E92D3B: puts (in /lib/libc-2.14.1

Kcachegrind/callgrind is inaccurate for dispatcher functions?

为君一笑 提交于 2019-12-01 04:53:07
问题 I have a model code on which kcachegrind/callgrind reports strange results. It is kind of dispatcher function. The dispatcher is called from 4 places; each call says, which actual do_J function to run (so the first2 will call only do_1 and do_2 and so on) Source (this is a model of actual code) #define N 1000000 int a[N]; int do_1(int *a) { int i; for(i=0;i<N/4;i++) a[i]+=1; } int do_2(int *a) { int i; for(i=0;i<N/2;i++) a[i]+=2; } int do_3(int *a) { int i; for(i=0;i<N*3/4;i++) a[i]+=3; } int

Valgrind Warning: Should I Take It Seriously

*爱你&永不变心* 提交于 2019-12-01 04:49:29
Background: I have a small routine that mimics fgets(character, 2, fp) except it takes a character from a string instead of a stream. newBuff is dynamically allocated string passed as a parameter and character is declared as char character[2] . Routine: character[0] = newBuff[0]; character[1] = '\0'; strcpy(newBuff, newBuff+1); The strcpy replicates the loss of information as each character is read from it. Problem: Valgrind does warns me about this activity, "Source and destination overlap in strcpy(0x419b818, 0x419b819)". Should I worry about this warning? Probably the standard does not