Mot*_*Kia 1 fortran valgrind openmp segmentation-fault
我用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)
Run Code Online (Sandbox Code Playgroud)
一切都好吗?
==7966== total heap usage: 340 allocs, 321 frees, 75,007 bytes allocated
这意味着一些记忆没有被解除分配?我的所有变量都是静态的.
segmentation fault
会发生.这些记忆可能导致这个问题?编辑:我运行代码
valgrind --leak-check=yes ./a.out
Run Code Online (Sandbox Code Playgroud)
这是摘要:
==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)
Run Code Online (Sandbox Code Playgroud)
我找不到问题,这就是第225行
free_energy(d) = -log(abs(correlation_fun(d)))
Run Code Online (Sandbox Code Playgroud)
问题是未初始化变量的用法.你必须找出它是哪一个,并确保它有一个有意义的价值.没有完整的代码,没有什么可以说的了.很可能d
没有正确定义价值.
仍然可以访问的内存通常是正常的.那不是泄密.通常,这些是您可以解除分配的可分配变量.它们可能位于模块中或主程序中,也可能在save
其他任何地方声明.程序完成后,它们不会自动解除分配,通常不会出现问题.
导致问题的真正的内存泄漏是当你丢失指向某个内存的指针然后你无法解除分配它.如果反复这样做,可能会浪费大量内存.然而,在valgrind看起来不同.然后你看definitely lost
,indirectly lost
或possibly lost
.