valgrind

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

独自空忆成欢 提交于 2019-11-30 08:44:48
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 nicer if could replace cerr with a thread-safe version, similar to the approach explained in the valgrind DRD manual ( http://valgrind.org/docs/manual/drd-manual.html#drd-manual.effective-use ) which involves deriving a class from std::ostreambuf. Ideally in the end I would just replace cerr with my own threaded cerr, e.g. simply: tcerr << "my variable: "

When a program terminates what happens to the memory allocated using malloc that is not free'ed?

╄→гoц情女王★ 提交于 2019-11-30 07:56:41
问题 Say I have the following program #include <stdio.h> #include <stdlib.h> int main(void) { int * i; if ((i = malloc(sizeof(int) * 100)) == NULL) { printf("EROOR: unable to allocate memory \n"); return -1; } /* memory is allocated successfully */ /* memory is not free'ed but program terminates */ // free(i); return 0; } The above program calls malloc to allocate some memory and does not call free to de-allocate it. And the program terminates without de-allocating the memory. Valgrind clearly

Android: tools to find memory leaks? [closed]

瘦欲@ 提交于 2019-11-30 07:56:23
Are there some useful tools to detect memory leaks in Android Java applications? Something similar to Valgrind where the place of creation of a non-freed object is shown? Watch this: http://www.youtube.com/watch?v=_CruQY55HOk Then install MAT for Eclipse . Happy hounting! read this post on Android Developer Blog, it has what you need http://android-developers.blogspot.com/2011/03/memory-analysis-for-android.html 来源: https://stackoverflow.com/questions/12041297/android-tools-to-find-memory-leaks

valgrind on the ARM9?

[亡魂溺海] 提交于 2019-11-30 07:29:12
问题 I see that valgrind has an ARM7 target, but I find conflicting information on whether valgrind has support for the ARM9. The ARM9 target I am working with is running linux. Has anyone specifically succeeded in using valgrind on an ARM9 target? If so, any pointers you can offer would be helpful, including "how did you build it?". Thanks -z 回答1: Valgrind runs on ARM-v7 (architecture name), not ARM7 (chip family name). ARM7 is a name of a fairly old chip family (which uses architecture ARM-v4),

Locate bad memory access on Solaris

岁酱吖の 提交于 2019-11-30 07:01:12
问题 On Linux, FreeBSD and other systems I have valgrind for checking for memory errors like invalid reads and similar. I really love valgrind. Now I have to test code on Solaris/OpenSolaris and can't find a way to get information on invalid reads/writes in an as nice way (or better ;-)) as valgrind there. When searching for this on the net I find references to libumem, but I get only reports about memory leaks there, not invalid access. What am I missing? 回答1: The dbx included with the Sun Studio

valgrind Conditional jump or move depends on uninitialised value(s) , does this indicate memory leak?

我们两清 提交于 2019-11-30 05:20:38
I am facing a memory leak problem in the code, while its running, the heap goes on increasing to maximum and i need to restart the service, I ran top command and see that the heap is increasing whenever im invoking a scenario in the service. I ran the service with valgrind , valgrind --log-file=log-feb19.txt --leak-check=full --show-reachable=yes --track-origins=yes myservice I donot see any definitely lost or possibly lost blocks while iam running the scenarios but i see a lot of Conditional jump or move depends on uninitialised value(s) errors. Do these count for a memory leak? Example of

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

时光总嘲笑我的痴心妄想 提交于 2019-11-30 04:46:52
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, start collect profile data after the operation is done, end collecting profile data analyze the profiling data. I can do this kind of thing using sun studio on Solaris. (using dbx ). I just want to know is it possible to do the same thing using valgrind(callgrind)?

Callgrind: Profile a specific part of my code

柔情痞子 提交于 2019-11-30 03:57:39
I'm trying to profile (with Callgrind) a specific part of my code by removing noise and computation that I don't care about. Here is an example of what I want to do: for (int i=0; i<maxSample; ++i) { //Prepare data to be processed... //Method to be profiled with these data //Post operation on the data } My use-case is a regression test, I want to make sure that the method in question is still fast enough (something like less than 10% extra instructions since the last implementation). This is why I'd like to have the cleaner output form Callgrind. (I need a for loop in order to have a

valgrind实操总结.一

南笙酒味 提交于 2019-11-29 23:35:08
valgrind神器 -----“优先使用gdb调试解决问题,不能解决的问题请使用该神器”。---- valgrind神器:是一款用于内存调试、内存泄漏检测以及性能分析的软件开发工具。 解压并编译工具: #tar xvf valgrind-3.9.0.tar.bz2 #apt-get install automake #./autogen.sh 修改configure中armv7 ) 改成 armv7 |arm) #./configure --host=arm-linux CC=arm-xilinx-linux-gnueabi-gcc CPP=arm-xilinx-linux-gnueabi-cpp CXX=aarm-xilinx-linux-gnueabi-g++ --prefix=/home/workdir/valgrind-3.9.0/valgrind_install #make; make install 单板配置并运行: #export PATH="$PATH:/mnt/nfs/wei.li/valgrind/bin" #export VALGRIND_LIB="/mnt/nfs/wei.li/valgrind/lib/valgrind" #valgrind --tool=memcheck --log-file=./valgrind_report.log --leak

pthread_exit vs. return

女生的网名这么多〃 提交于 2019-11-29 21:19:41
I have a joinable pthread runner function defined as below: void *sumOfProducts(void *param) { ... pthread_exit(0); } This thread is supposed to join the main thread. Whenever I ran my program through Valgrind I would get the following leaks : LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks indirectly lost: 0 bytes in 0 blocks possibly lost: 0 bytes in 0 blocks still reachable: 968 bytes in 5 blocks suppressed: 0 bytes in 0 blocks ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 15 from 10) I checked the man page for pthreads which said: The new thread terminates in one of the following