valgrind

Valgrind understanding bytes allocated increase in heap summary?

允我心安 提交于 2019-12-07 16:38:11
问题 I have been looking at debugging the memory usage in a forking TCP server. I think I am doing pretty well, I just can't seem to find information on the 'bytes allocated' number in the 'heap summary'. This number seems to be ever increasing the longer my server runs: ==27526== ==27526== HEAP SUMMARY: ==27526== in use at exit: 0 bytes in 0 blocks ==27526== total heap usage: 113 allocs, 113 frees, 283,043 bytes allocated ==27526== ==27526== All heap blocks were freed -- no leaks are possible =

valgrind giving error but unable to find location

Deadly 提交于 2019-12-07 16:12:14
问题 I have started using valgrind just one day ago as suggested by someone on SO itself .Its an amazing tool but today i got an issue with it.It gives the following error : definitely lost bytes but unable to tell the location of error. Here is the output of valgrind : udit@udit-Dabba ~ $ valgrind --leak-check=full sendip -v -p ipv6 -f file.txt -6s ::1 -p ah -as 0x20 -aq 0x40 -ak "yugal" -am xorauth.so -p udp -us 21 - ud 21 ::2 ==12885== Memcheck, a memory error detector ==12885== Copyright (C)

memory leak in dgemm_

房东的猫 提交于 2019-12-07 13:01:06
问题 I am currently working on an application which involves lots and lots of calls to blas routines. Routinely checking for memory leaks I discovered, that I am loosing bytes in a dgemm call. The call looks like this: // I want to multiply 2 nxn matrices and put the result into C - an nxn matrix double zero = 0.0; double one = 1.0; double n; // matrix dimension char N = 'N'; dgemm_(&N, &N, &n, &n, &n, &one, A, &n, B, &n, &zero, C, &n); A,B and C are double fields of size n*n. The valgrind output

getpwnam_r memory leak

亡梦爱人 提交于 2019-12-07 08:49:29
问题 I use getpwnam_r to handle client connections in my programs. Sadly enough, it seems to allocate a buffer it never frees. The relevant valgrind output: ==15774== 536 (104 direct, 432 indirect) bytes in 2 blocks are definitely lost in loss record 1 of 3 ==15774== at 0x4C24CFE: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so) ==15774== by 0x5143B5A: nss_parse_service_list (in /lib64/libc-2.10.1.so) ==15774== by 0x51442E6: __nss_database_lookup (in /lib64/libc-2.10.1.so) ==15774

Valgrind使用说明

老子叫甜甜 提交于 2019-12-07 07:09:19
Valgrind使用说明 Valgrind是运行在Linux上一套基于仿真技术的程序调试和分析工具,是公认的最接近Purify的产品,它包含一个内核——一个软件合成的CPU,和一系列的小工具,每个工具都可以完成一项任务——调试,分析,或测试等。Valgrind可以检测内存泄漏和内存越界,还可以分析cache的使用等,灵活轻巧而又强大。 一 Valgrind概观 Valgrind的最新版是3.2.3,该版本包含下列工具: 1、memcheck:检查程序中的内存问题,如泄漏、越界、非法指针等。 2、callgrind:检测程序代码覆盖,以及分析程序性能。 3、cachegrind:分析CPU的cache命中率、丢失率,用于进行代码优化。 4、helgrind:用于检查多线程程序的竞态条件。 5、massif:堆栈分析器,指示程序中使用了多少堆内存等信息。 6、lackey: 7、nulgrind: 二 Valgrind工具详解 1.Memcheck 最常用的工具,用来检测程序中出现的内存问题,所有对内存的读写都会被检测到,一切对malloc、free、new、delete的调用都会被捕获。所以,它能检测以下问题: 1、对未初始化内存的使用; 2、读/写释放后的内存块; 3、读/写超出malloc分配的内存块; 4、读/写不适当的栈中内存块; 5、内存泄漏,指向一块内存的指针永远丢失;

Address 0x0 is not stack'd, malloc'd or (recently) free'd

℡╲_俬逩灬. 提交于 2019-12-07 04:39:53
问题 I'm very new to C, and can't seem to figure out what's wrong with the following code. int main() { char filen[] = "file.txt"; FILE *file = fopen ( filen, "r" ); if ( file != NULL ) { char line [ 128 ]; while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */ { int i; char *result; for(i=0; i< NUM;i++) { char *rep; rep = (char *) malloc (sizeof(mychars[i][0])); strcpy(rep, mychars[i][0]); char *with; with = (char *) malloc (sizeof(mychars[i][1])); strcpy(with, cgichars[i][1]);

How to correctly (and effectively) release memory in a gtk widget

孤街醉人 提交于 2019-12-07 03:18:27
问题 I'm trying to understand how to correctly release memory when I am finished with a GTK widget, for example if I need to create and destroy many widgets. However, valgrind seems to indicate a memory leak regardless of what I try. I've looked at other questions, including one that lists a valgrind supression file for GTK, but it didn't change the result. Here's the simplest code snippet to reproduce my issue: #include "gtk/gtk.h" int main() { GtkWidget * widget = gtk_fixed_new(); g_object_ref

What's wrong with this boost::asio and boost::coroutine usage pattern?

倖福魔咒の 提交于 2019-12-07 02:42:30
问题 In this question I described boost::asio and boost::coroutine usage pattern which causes random crashes of my application and I published extract from my code and valgrind and GDB output. In order to investigate the problem further I created smaller proof of concept application which applies the same pattern. I saw that the same problem arises in the smaller program which source I publish here. The code starts a few threads and creates a connection pool with a few dummy connections (user

Valgrind giving errors with getline()

时间秒杀一切 提交于 2019-12-07 02:39:18
问题 I have a function which calls getline() , which reads lines from a standard text file. These lines end in \r\n , as this is what the spec calls for as it is the "internet standard" for VCARD files. Anyway, I run this baby through Valgrind on OpenSUSE 11.3 with the latest GCC and Valgrind versions; no errors. However, for reasons of no relevance to this problem, I switched distros to Back Track 4 (Ubuntu based), and now I am getting a metric ton of Valgrind errors: ==21536== Conditional jump

What is the equivalent of Valgrind within the Xcode environment?

 ̄綄美尐妖づ 提交于 2019-12-07 02:17:15
问题 It was recently recommended to me to use Valgrind to check for memory leaks, errors etc. on my iPhone project (which is written mainly in C and Objective-C). I'm fairly new to this kind of work and was wondering what tools there were in Xcode that would serve the same purpose. Thanks so much 回答1: If you want to check memory leaks then you can run your project with performance tool with leaks. Follow the screen shot. 回答2: http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind