如何解释 Valgrind 输出
How to interpret Valgrind output
Valgrind 生成以下消息块:
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)
如何阅读此消息?
main.cpp 第 374 行显示:
results[index] = compute(parameters, weights);
是否恰好在 main.cpp 的第 374 行内存泄漏?它是在 compute() 中泄漏还是在 assignment/indexing 处泄漏到结果中?
Is memory leaked exactly at line 374 of main.cpp?
没有。它仅显示 main
中进行调用的行号,最终导致分配内存的函数和行。
Is it leaked in compute() or maybe at assignment/indexing into results?
它说内存在 compute()
中分配,但在程序退出之前没有在程序中释放。这就是内存泄漏。
Valgrind 生成以下消息块:
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)
如何阅读此消息?
main.cpp 第 374 行显示:
results[index] = compute(parameters, weights);
是否恰好在 main.cpp 的第 374 行内存泄漏?它是在 compute() 中泄漏还是在 assignment/indexing 处泄漏到结果中?
Is memory leaked exactly at line 374 of main.cpp?
没有。它仅显示 main
中进行调用的行号,最终导致分配内存的函数和行。
Is it leaked in compute() or maybe at assignment/indexing into results?
它说内存在 compute()
中分配,但在程序退出之前没有在程序中释放。这就是内存泄漏。