valgrind

How use callgrind to profiling only a certain period of program execution?

I want to use valgrind to do some profiling, since it does not need re-build the program. (the program I want to profile is already build with “-g") But valgrind(callgrind) is quite slow ... so here's what I to do: start the server ( I want to profile that server) kind of attach to that server before I do some operation on server, sta...

mem-leak freeing g_strdup

I'm trying to free g_strdup but I'm not sure what I'm doing wrong. Using valgrind --tool=memcheck --leak-check=yes ./a.out I keep getting: ==4506== 40 bytes in 10 blocks are definitely lost in loss record 2 of 9 ==4506== at 0x4024C1C: malloc (vg_replace_malloc.c:195) ==4506== by 0x40782E3: g_malloc (in /lib/libglib-2.0.so.0.2200...

How can I use valgrind for memory profile

Hi, Can you please tell me how can I use valgrind for memory profile? The article I found from google talks about how to use valgrind for memory leak. I am interested in how to use that for memory profiling (i.e. how much memory is used by what classes)? Thank you. ...

understanding valgrind output

Hi, i made a post earlier asking about checking for memory leaks etc, i did say i wasnt to familiar with the terminal in linux but someone said to me it was easy with valgrind i have managed to get it running etc but not to sure what the output means. Glancing over, all looks good to me but would like to run it past you experience folk ...

valgrind on server process

hi i am new to valgrind. I know how to run valgrind on executable files from command line. But how do you run valgrind on server processes like apache/myqld/traffic server etc .. I want to run valgrind on traffic server (http://incubator.apache.org/projects/trafficserver.html) to detect some memory leaks taking place in the plugin I ha...

gethostbyname() and valgrind

Hello, I keep getting this error whenever I call gethostbyname() in my C code. ==7983== Invalid read of size 1 ==7983== at 0x412AB2C: ____strtoul_l_internal (strtol_l.c:298) ==7983== by 0x412A46F: strtoul (strtol.c:110) ==7983== by 0x41D427E: inet_aton (inet_addr.c:143) ==7983== by 0x41D8FF3: __nss_hostname_digits_dots (digi...

valgrind complains doing a very simple strtok in c

Hi I'm trying to tokenize a string by loading an entire file into a char[] using fread. For some strange reason it is not always working, and valgrind complains in this very small sample program. Given an input like test.txt first second And the following program #include <stdio.h> #include <string.h> #include <stdlib.h> #include <s...

Using Valgrind tool how can I detect which object trying to access 0x0 address ?

I have this output when trying to debug Program received signal SIGSEGV, Segmentation fault 0x43989029 in std::string::compare (this=0x88fd430, __str=@0xbfff9060) at /home/devsw/tmp/objdir/i686-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:253 253 { return memcmp(__s1, __s2, __n); } Current language: auto; currently ...

pinpointing "conditional jump or move depends on uninitialized value(s)" valgrind message

So I've been getting some mysterious uninitialized values message from valgrind and it's been quite the mystery as of where the bad value originated from. Seems that valgrind shows the place where the unitialised value ends up being used, but not the origin of the uninitialised value. ==11366== Conditional jump or move depends on unini...

multiple valgrind errors: Conditional jump or move depends on uninitialised value(s)

I'm running valgrind and I'm getting the following error (this is not the only one): ==21743== Conditional jump or move depends on uninitialised value(s) ==21743== at 0x4A06509: index (mc_replace_strmem.c:164) ==21743== by 0x33B7CBB3CD: gaih_inet (in /lib64/libc-2.5.so) ==21743== by 0x33B7CBD629: getaddrinfo (in /lib64/libc-2.5...

Valgrind suppression file for Qt 4.6.2 and RHEL 5

I'm trying to run Valgrind 3.5.0 on RHEL 5.5 with Qt 4.6.2. It's producing loads of spurious errors and I'm wondering if anyone can share a suppressions file they've built? When using --leak-check=full, the output reports leaks in glib, gtk, pango etc. even when I'm just running part7 of the AddressBook example. With over 25000 lines th...

How to detect segmentation fault details using Valgrind?

Hi all I have a std::map< std::string, std::string> which initialized with some API call. When I'm trying to use this map I'm getting segmentation fault. How can I detect invalid code or what is invalid or any detail which can help me to fix problem? Code looks like this: std::map< std::string, std::string> cont; some_func( cont ); //...

Valgrind says "stack allocation," I say "heap allocation"

Dear Friends, I am trying to trace a segfault with valgrind. I get the following message from valgrind: ==3683== Conditional jump or move depends on uninitialised value(s) ==3683== at 0x4C277C5: sparse_mat_mat_kron (sparse.c:165) ==3683== by 0x4C2706E: rec_mating (rec.c:176) ==3683== by 0x401C1C: age_dep_iterate (age_dep.c:28...

daynamic 2d array in c++ and memory leaks

Hi guys, i wrote this code, it runs ok, but when i check it under Valgrind it catches 2 problems, since i can not interpret valgrind's messages i will appreciate if anyone explain me more and tell me where is the problem!!! here is the code: #include <iostream> #define width 70000 #define height 10000 using namespace std; int main...

C program runs in Cygwin but not Linux (Malloc)

I have a heap allocation error that I cant spot in my code that is picked up on vanguard/gdb on Linux but runs perfectly on a Windows cygwin environment. I understand that Linux could be tighter with its heap allocation than Windows but I would really like to have a response that discovers the issue/possible fix. I'm also aware that I ...

Difference in behaviour (GCC and Visual C++)

Consider the following code. #include <stdio.h> #include <vector> #include <iostream> struct XYZ { int X,Y,Z; }; std::vector<XYZ> A; int rec(int idx) { int i = A.size(); A.push_back(XYZ()); if (idx >= 5) return i; A[i].X = rec(idx+1); return i; } int main(){ A.clear(); rec(0); puts("FINISH!"); } I coul...

Need help in reading callgrind output

Hi, I have run callgrind with my application like this "valgrind --tool=callgrind MyApplication" and then call 'callgrind_annotate --auto=yes ./callgrind.out.2489' I see output like 768,097,560 PROGRAM TOTALS -------------------------------------------------------------------------------- Ir file:function ------------------...

Need help in understanding kcachedgrind output

Hi, I am using valgrind callgrind to profile a program on gtk. And then I use kcachedgrind to read the result. I have captured an update a screenshot of kcachedgrind here: http://i41.tinypic.com/168spk0.jpg. It said the function gtk_moz_embed_new() costed '15.61%'. But I dont understand how is that possible. the function gtk_moz_embed_n...

Valgrind 'noise', what does it mean?

When I used valgrind to help debug an app I was working on I notice a huge about of noise which seems to be complaining about standard libraries. As a test I did this; echo 'int main() {return 0;}' | gcc -x c -o test - Then I did this; valgrind ./test ==1096== Use of uninitialised value of size 8 ==1096== at 0x400A202: _dl_new_o...

Is valgrind crazy or is this is a genuine std map iterator memory leak?

Well, I'm very new to Valgrind and memory leak profilers in general. And I must say it is a bit scary when you start using them cause you can't stop wondering how many leaks you might have left unsolved before! To the point, as I'm not an experienced in c++ programmer, I would like to check if this is certainly a memory leak or is it th...