Valgrind 摘要是什么意思?
what does Valgrind summary mean?
我 运行 我使用 Valgrind 的 Fortran 代码,这是摘要:
==7966== HEAP SUMMARY:
==7966== in use at exit: 13,254 bytes in 19 blocks
==7966== total heap usage: 340 allocs, 321 frees, 75,007 bytes allocated
==7966==
==7966== LEAK SUMMARY:
==7966== definitely lost: 0 bytes in 0 blocks
==7966== indirectly lost: 0 bytes in 0 blocks
==7966== possibly lost: 0 bytes in 0 blocks
==7966== still reachable: 13,254 bytes in 19 blocks
==7966== suppressed: 0 bytes in 0 blocks
==7966== Reachable blocks (those to which a pointer was found) are not shown.
==7966== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==7966==
==7966== For counts of detected and suppressed errors, rerun with: -v
==7966== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
1。一切都好吗?
==7966== total heap usage: 340 allocs, 321 frees, 75,007 bytes allocated
这意味着有些内存没有释放?我所有的变量都是静态的。
- 我的串行代码运行良好,但是当我使其与 OpenMP 并行并且对于大数据时,会出现
segmentation fault
。这些记忆可能会导致这个问题吗?
编辑:我运行代码
valgrind --leak-check=yes ./a.out
这是摘要:
==9825== Conditional jump or move depends on uninitialised value(s)
==9825== at 0x41630D9: log (w_log.c:28)
==9825== by 0x804D052: MAIN__ (main.f90:225)
==9825== by 0x804D128: main (main.f90:231)
==9825==
==9825== Conditional jump or move depends on uninitialised value(s)
==9825== at 0x4158E88: __ieee754_log (e_log.S:16)
==9825== by 0x41630EF: log (w_log.c:42)
==9825== by 0x804D052: MAIN__ (main.f90:225)
==9825== by 0x804D128: main (main.f90:231)
==9825==
==9825== HEAP SUMMARY:
==9825== in use at exit: 0 bytes in 0 blocks
==9825== total heap usage: 12,023 allocs, 12,023 frees, 96,007,152 bytes allocated
==9825==
==9825== All heap blocks were freed -- no leaks are possible
==9825==
==9825== For counts of detected and suppressed errors, rerun with: -v
==9825== Use --track-origins=yes to see where uninitialised values come from
==9825== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
我找不到问题,这是第225行
free_energy(d) = -log(abs(correlation_fun(d)))
根据此行,您正在泄漏内存:==7966== 仍可访问:19 个块中的 13,254 字节
尝试按照建议使用 --leak-check=full --show-leak-kinds=all 重新运行,并使用编译标志进行编译以跟踪哪些变量正在泄漏。即使变量是静态的,如果它们是堆分配的,它们仍然会泄漏内存。
段错误最好用 gdb 调试,但内存泄漏可能会导致它。
问题是未初始化变量的用法。您必须找出它是哪一个并确保它具有有意义的值。 没有完整的代码就没什么好说的了。很可能 d
的值没有正确定义。
仍然可以访问的内存通常是可以的。那是不是泄漏。通常,这些是您没有解除分配的可分配变量。它们可能在模块或主程序中或在其他任何地方声明为 save
。它们不会在程序结束时自动释放,这通常不是问题。
真正的内存泄漏会导致问题,当您丢失指向某些内存的指针时,您将无法释放它。如果你重复这样做,你可能会浪费很多内存。然而,这在 valgrind 中看起来不同。然后您会看到 definitely lost
、indirectly lost
或 possibly lost
.
我 运行 我使用 Valgrind 的 Fortran 代码,这是摘要:
==7966== HEAP SUMMARY:
==7966== in use at exit: 13,254 bytes in 19 blocks
==7966== total heap usage: 340 allocs, 321 frees, 75,007 bytes allocated
==7966==
==7966== LEAK SUMMARY:
==7966== definitely lost: 0 bytes in 0 blocks
==7966== indirectly lost: 0 bytes in 0 blocks
==7966== possibly lost: 0 bytes in 0 blocks
==7966== still reachable: 13,254 bytes in 19 blocks
==7966== suppressed: 0 bytes in 0 blocks
==7966== Reachable blocks (those to which a pointer was found) are not shown.
==7966== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==7966==
==7966== For counts of detected and suppressed errors, rerun with: -v
==7966== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
1。一切都好吗?
==7966== total heap usage: 340 allocs, 321 frees, 75,007 bytes allocated
这意味着有些内存没有释放?我所有的变量都是静态的。
- 我的串行代码运行良好,但是当我使其与 OpenMP 并行并且对于大数据时,会出现
segmentation fault
。这些记忆可能会导致这个问题吗?
编辑:我运行代码
valgrind --leak-check=yes ./a.out
这是摘要:
==9825== Conditional jump or move depends on uninitialised value(s)
==9825== at 0x41630D9: log (w_log.c:28)
==9825== by 0x804D052: MAIN__ (main.f90:225)
==9825== by 0x804D128: main (main.f90:231)
==9825==
==9825== Conditional jump or move depends on uninitialised value(s)
==9825== at 0x4158E88: __ieee754_log (e_log.S:16)
==9825== by 0x41630EF: log (w_log.c:42)
==9825== by 0x804D052: MAIN__ (main.f90:225)
==9825== by 0x804D128: main (main.f90:231)
==9825==
==9825== HEAP SUMMARY:
==9825== in use at exit: 0 bytes in 0 blocks
==9825== total heap usage: 12,023 allocs, 12,023 frees, 96,007,152 bytes allocated
==9825==
==9825== All heap blocks were freed -- no leaks are possible
==9825==
==9825== For counts of detected and suppressed errors, rerun with: -v
==9825== Use --track-origins=yes to see where uninitialised values come from
==9825== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
我找不到问题,这是第225行
free_energy(d) = -log(abs(correlation_fun(d)))
根据此行,您正在泄漏内存:==7966== 仍可访问:19 个块中的 13,254 字节
尝试按照建议使用 --leak-check=full --show-leak-kinds=all 重新运行,并使用编译标志进行编译以跟踪哪些变量正在泄漏。即使变量是静态的,如果它们是堆分配的,它们仍然会泄漏内存。
段错误最好用 gdb 调试,但内存泄漏可能会导致它。
问题是未初始化变量的用法。您必须找出它是哪一个并确保它具有有意义的值。 没有完整的代码就没什么好说的了。很可能 d
的值没有正确定义。
仍然可以访问的内存通常是可以的。那是不是泄漏。通常,这些是您没有解除分配的可分配变量。它们可能在模块或主程序中或在其他任何地方声明为 save
。它们不会在程序结束时自动释放,这通常不是问题。
真正的内存泄漏会导致问题,当您丢失指向某些内存的指针时,您将无法释放它。如果你重复这样做,你可能会浪费很多内存。然而,这在 valgrind 中看起来不同。然后您会看到 definitely lost
、indirectly lost
或 possibly lost
.