Ranju
Ranju

Reputation: 76

valgrind showing same memory leak multiple times in log file

I work in a MnC software company. My task is to fix memory leaks in the software. I am using valgrind memcheck tool. I used 'valgrind --leak-check=yes --log-file=vg.log '. I found that valgrind is showing same memory leak multiples times in different sizes in vg.log and the vg.log file has 2 million lines. As a result I am not able to identify which leak has highest size. I mean which one is the biggest leak. Do you have any idea to solve this issue? I want same memory leak should come once in vg.log with aggregate size.I am using val3.12.0 version of valgrind. I am using Red Hat Enterprise Linux Workstation release 6.5.

Upvotes: 0

Views: 450

Answers (2)

Ranju
Ranju

Reputation: 76

Actually valgrind has a --num-callers option which can used to club different similar memory leaks.

Upvotes: 0

Paul Floyd
Paul Floyd

Reputation: 6946

The leaks are dumped in order of increasing size. Therefore the last leak is the biggest one. Each leak description looks something like

XX bytes in B blocks are definitely lost in loss record R of N

where

  • XX is the total size of the leak for that callstack
  • B is the number of times there is a leak with that callstack. For instance, if the total is 4096 bytes in 4 blocks that means that the call happens 4 times and each leak is 1024 bytes
  • R is the running count of the leaks
  • N is the total number of different leak callstacks

Upvotes: 0

Related Questions