I write code that uses MPI and I continued to notice memory leaks when starting with valgrind. Trying to determine what the problem is, I ended up with this simple (and completely useless) core:
#include "/usr/include/mpi/mpi.h" int main(int argc,char** argv) { MPI_Init(&argc, &argv); MPI_Finalize(); return 0; }
As you can see, this code does nothing and should not cause any problems. However, when I run the code with valgrind (in both serial and parallel cases), I get the following summary:
== 28271 == HEAP SUMMARY:
== 28271 == used on exit: 190 826 bytes in 2745 blocks
== 28271 == total heap usage: 11,214 allocs, 8,469 frees, 16,487,977 bytes allocated
== 28271 ==
== 28271 == CONTENTS:
== 28271 == definitely lost: 5,950 bytes in 55 blocks
== 28271 == indirectly lost: 3,562 bytes in 32 blocks
== 28271 == possibly lost: 0 bytes in 0 blocks
== 28271 == still available: 181.314 bytes in 2.658 blocks
== 28271 == suppressed: 0 bytes in 0 blocks
I do not understand why there are these leaks. Maybe I just couldn't read the output of valgrind or use MPI initialization / termination correctly ...
I am using OMPI 1.4.1-3 under ubuntu in 64bit architecture if this can help.
Thanks so much for your time!