MPI 内存泄漏 [英] MPI memory leak

查看:33
本文介绍了MPI 内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些使用 MPI 的代码,并且在使用 valgrind 运行它时我一直注意到一些内存泄漏.在试图确定问题出在哪里时,我最终得到了这个简单(而且完全没用)的 main:

I am writing some code that uses MPI and I was keeping noticing some memory leaks when running it with valgrind. While trying to identify where the problem was, I ended up with this simple (and totally useless) main:

#include "/usr/include/mpi/mpi.h"

int main(int argc,char** argv)
{
MPI_Init(&argc, &argv);
MPI_Finalize();
return 0;
}

如您所见,此代码不会执行任何操作,也不应该产生任何问题.但是,当我使用 valgrind 运行代码时(在串行和并行情况下),我得到以下摘要:

As you can see, this code doesn't do anything and shouldn't create any problem. However, when I run the code with valgrind (both in the serial and parallel case), I get the following summary:

==28271== 堆摘要:

==28271== HEAP SUMMARY:

==28271== 在退出时使用:2,745 个块中有 190,826 字节

==28271== in use at exit: 190,826 bytes in 2,745 blocks

==28271== 总堆使用量:11,214 次分配,8,469 次释放,16,487,977 字节分配

==28271== total heap usage: 11,214 allocs, 8,469 frees, 16,487,977 bytes allocated

==28271==

==28271== 泄漏摘要:

==28271== LEAK SUMMARY:

==28271== 肯定丢失了:55 个块中有 5,950 个字节

==28271== definitely lost: 5,950 bytes in 55 blocks

==28271== 间接丢失:32 个块中 3,562 个字节

==28271== indirectly lost: 3,562 bytes in 32 blocks

==28271== 可能丢失:0 个块中的 0 个字节

==28271== possibly lost: 0 bytes in 0 blocks

==28271== 仍然可达:2,658 个块中有 181,314 个字节

==28271== still reachable: 181,314 bytes in 2,658 blocks

==28271== 被抑制:0 个块中的 0 个字节

==28271== suppressed: 0 bytes in 0 blocks

我不明白为什么会有这些泄漏.也许只是我无法读取 valgrind 输出或正确使用 MPI 初始化/终结...

I don't understand why there are these leaks. Maybe it's just me not able to read the valgrind output or to use MPI initialization/finalization correctly...

我在 64 位架构的 ubuntu 下使用 OMPI 1.4.1-3,如果这有帮助的话.

I am using OMPI 1.4.1-3 under ubuntu on a 64 bit architecture, if this can help.

非常感谢您的时间!

推荐答案

你没有做错任何事.valgrind 的 Memcheck 误报很常见,你能做的最好的事情就是抑制它们.

You're not doing anything wrong. Memcheck false positives with valgrind are common, the best you can do is suppress them.

本页详细介绍了这些误报.接近尾声的引用:

This page of the manual speaks more about these false positives. A quote near the end:

包装器应降低 Memcheck 在 MPI 上的误报率应用程序.因为包装是在 MPI 接口完成的,所以有仍然可能会在 MPI 中报告大量错误接口下面的实现.你能做的最好的事情就是尝试压制他们.

The wrappers should reduce Memcheck's false-error rate on MPI applications. Because the wrapping is done at the MPI interface, there will still potentially be a large number of errors reported in the MPI implementation below the interface. The best you can do is try to suppress them.

这篇关于MPI 内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆