Konsta
Konsta

Reputation: 377

How to interpret Valgrind output

Valgrind yields the following message block:

1,065,024 bytes in 66,564 blocks are definitely lost in loss record 21 of 27
   at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x40CA21: compute(Parameters&, Array<double>&) [clone .constprop.71] (array.hpp:135)
   by 0x403E70: main (main.cpp:374)

How to read this message?

main.cpp line 374 reads:

results[index] = compute(parameters, weights);

Is memory leaked exactly at line 374 of main.cpp? Is it leaked in compute() or maybe at assignment/indexing into results?

Upvotes: 0

Views: 1500

Answers (1)

R Sahu
R Sahu

Reputation: 206717

Is memory leaked exactly at line 374 of main.cpp?

No. It just shows the line number in main where the call was made that ultimately leads to the function and line where the memory was allocated.

Is it leaked in compute() or maybe at assignment/indexing into results?

It says that memory was allocated in compute() but was not deallocated in the program before the program exited. That's what constitutes a memory leak.

Upvotes: 3

Related Questions