valgrind

How to use valgrind with python?

狂风中的少年 提交于 2019-11-26 19:45:51
I am trying to memcheck a C python extension I am writing, but I'm having trouble setting up valgrind to work with python. I would really appreciate some advice. Just for context, this is Ubuntu 13.10, python 2.7.5+, and valgrind 3.8.1. As per recommendation from Readme.valgrind I did the following. 1) Downloaded the python source with sudo apt-get build-dep python2.7 apt-get source python2.7 2) Applied the code patch, i.e. "Uncomment Py_USING_MEMORY_DEBUGGER in Objects/obmalloc.c". 3) Applied the suppression patch, i.e. "Uncomment the lines in Misc/valgrind-python.supp that suppress the

How do I use valgrind to find memory leaks?

可紊 提交于 2019-11-26 19:15:17
How do I use valgrind to find the memory leaks in a program? Please someone help me and describe the steps to carryout the procedure? I am using Ubuntu 10.04 and I have a program a.c , please help me out. How to Run Valgrind I would like to build a more verbose explanation for how to use Valgrind effectively and how to resolve memory leaks. Not to insult the OP, but for those who come to this question and are still new to Linux— you might have to install Valgrind on your system. sudo apt install valgrind # Ubuntu, Debian, etc. sudo yum install valgrind # RHEL, CentOS, Fedora, etc. Valgrind is

valgrind简单用法【转】

自闭症网瘾萝莉.ら 提交于 2019-11-26 18:33:50
原文: http://www.cnblogs.com/sunyubo/archive/2010/05/05/2282170.html Valgrind的主要作者Julian Seward刚获得了今年的Google-O'Reilly开源大奖之一──Best Tool Maker。让我们一起来看一下他的作品。Valgrind是运行在Linux上一套基于仿真技术的程序调试和分析工具,它包含一个内核──一个软件合成的CPU,和一系列的小工具,每个工具都可以完成一项任务──调试,分析,或测试等。Valgrind可以检测内存泄漏和内存违例,还可以分析cache的使用等,灵活轻巧而又强大,能直穿程序错误的心脏,真可谓是程序员的瑞士军刀。 一. Valgrind概观 Valgrind的最新版是3.2.0,它一般包含下列工具: 1.Memcheck 最常用的工具,用来检测程序中出现的内存问题,所有对内存的读写都会被检测到,一切对malloc()/free()/new/delete的调用都会被捕获。所以,它能检测以下问题: 1.对未初始化内存的使用; 2.读/写释放后的内存块; 3.读/写超出malloc分配的内存块; 4.读/写不适当的栈中内存块; 5.内存泄漏,指向一块内存的指针永远丢失; 6.不正确的malloc/free或new/delete匹配; 7,memcpy(

valgrind常用参数【转】

吃可爱长大的小学妹 提交于 2019-11-26 18:33:42
原文:http://www.cnblogs.com/wangkangluo1/archive/2011/06/10/2077450.html valgrind --leak-check=full --show-reachable=yes --log-file=a.log ./shdaily.fcgi "op=search&date=2011-04-14&current=4" glib使用如下: G_SLICE=always-malloc valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 ./egg2Utest "ItfTest" 常用命令详解: G_DEBUG=gc-friendly G_SLICE=always-malloc //glib有缓存 故需使用 上述两条 设置环境变量 G_SLICE和G_DEBUG排除由内存分配机制带来的影响 --tool=memcheck //使用valgrind的memcheck功能 -show-reachable=yes // 是否检测控制范围之外的泄漏,比如全局指针、 static 指针等 --log-file=a.log //结果输出到文件 --leak-check=full // 显示具体代码中泄漏的地方 --leak

Why does valgrind say basic SDL program is leaking memory?

自闭症网瘾萝莉.ら 提交于 2019-11-26 18:18:17
问题 Here is the SDL program: #include <SDL/SDL.h> int main(int argc, char** argv){ SDL_Init(SDL_INIT_VIDEO); SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE); SDL_Quit(); return 0; } Compiled with the command: g++ -o test test.cpp -lSDL And here is the output of valgrind: christian@christian-laptop:~/cpp/tetris$ valgrind --leak-check=full ./test ==3271== Memcheck, a memory error detector ==3271== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al. ==3271== Using

How does valgrind work?

﹥>﹥吖頭↗ 提交于 2019-11-26 17:57:15
问题 Can someone provide a quick top level explanation of how Valgrind works? An example: how does it know when memory is allocated and freed? 回答1: Valgrind basically runs your application in a "sandbox." While running in this sandbox, it is able to insert its own instructions to do advanced debugging and profiling. From the manual: Your program is then run on a synthetic CPU provided by the Valgrind core. As new code is executed for the first time, the core hands the code to the selected tool.

Valgrind reports errors for a very simple C program

假装没事ソ 提交于 2019-11-26 17:55:51
I'm learning C language from Learn C The Hard Way . I'm on exercise 6 and while I can make it work, valgrind repots a lot of errors. Here's the stripped down minimal program from a file ex6.c : #include <stdio.h> int main(int argc, char *argv[]) { char initial = 'A'; float power = 2.345f; printf("Character is %c.\n", initial); printf("You have %f levels of power.\n", power); return 0; } Content of Makefile is just CFLAGS=-Wall -g . I compile the program with $ make ex6 (there are no compiler warnings or errors). Executing with $ ./ex6 produces the expected output. When I run the program with $

valgrind and openmp, still reachable and possibly lost, is that bad?

我与影子孤独终老i 提交于 2019-11-26 17:47:26
问题 c++ newbie here. I've been improving my memory management skills over the last few days, and my program no longer leaks memory according to valgrind. In fact, I get no warnings from valgrind at all. However, when I add openmp loops into my code, I start to get the following errors in valgrind (memcheck): (but no definitely lost blocks) ==6417== 304 bytes in 1 blocks are possibly lost in loss record 3 of 4 ==6417== at 0x4C279FC: calloc (vg_replace_malloc.c:467) ==6417== by 0x4011868: _dl

Memory Leaks in GTK hello_world program

怎甘沉沦 提交于 2019-11-26 17:23:34
问题 So... I'm trying to eliminate some memory leaks from my GTK+ 3 program. I though it would be a good idea to look back at some simple examples to see if there is some cleanup stuff I'm forgetting, but the hello_world program provided in the documentation has leaks too. (Valgrind output below). Are these leaks acceptable? If so, is there some other application I should be using to debug GTK programs? ==13717== Memcheck, a memory error detector ==13717== Copyright (C) 2002-2012, and GNU GPL'd,

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

女生的网名这么多〃 提交于 2019-11-26 17:09:48
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 uninitialised value(s) ==11366== at 0x43CAE4F: __printf_fp (in /lib/tls/i686/cmov/libc-2.7.so) ==11366== by 0x43C6563: vfprintf (in /lib/tls/i686/cmov/libc-2.7.so) ==11366== by 0x43EAC03: vsnprintf (in /lib/tls/i686/cmov/libc-2.7.so) ==11366== by 0x42D475B: (within