Get the free out of the #ifndef LEAK and your problem will be solved.

  george.

On May 13, 2012, at 11:18 , Ilja Honkonen wrote:

> Hello
> 
> The following program leaks memory if compiled with -DLEAK (uses about 7 GB 
> in the end but less than 20 MB without -DLEAK).
> 
> 
> #include "assert.h"
> #include "mpi.h"
> 
> int main(int argc, char* argv[]) {
>       assert(MPI_Init(&argc, &argv) == MPI_SUCCESS);
> 
>       for (int i = 0; i < 10000000; i++) {
>               MPI_Datatype type;
>               assert(
>                       MPI_Type_contiguous(
>                               10 * sizeof(double),
>                               MPI_BYTE,
>                               &type
>                       ) == MPI_SUCCESS
>               );
> 
>               #ifndef LEAK
>               assert(MPI_Type_commit(&type) == MPI_SUCCESS);
>               assert(MPI_Type_free(&type) == MPI_SUCCESS);
>               #endif
>       }
> 
>       assert(MPI_Finalize() == MPI_SUCCESS);
> }
> 
> Since uncommitted datatypes can be used for creating new ones (MPI-2.2) this 
> behavior seems like a rather nasty bug.
> 
> mpirun --version
> mpirun (Open MPI) 1.5.5
> 
> openmpi compiled with gcc (GCC) 4.5.2
> above program compiled and ran with
> mpicc -DLEAK -O3 leak.c -std=c99 && mpirun -np 1 ./a.out
> on a single AMD Phenom(tm) II X6 1075T processor. Same thing happens when 
> compiling with mpic++.
> 
> I can't use memchecker because then mpirun segfaults and even
> ompi_info | grep memchecker
> segfaults after printing MCA memchecker: valgrind (...
> 
> Thanks.
> Ilja
> _______________________________________________
> users mailing list
> us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/users


Reply via email to