From 57eb68c60e9df9b43e77bbe9e4cf282a69ce8cae Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Mon, 16 Sep 2024 23:16:20 +0200
Subject: [PATCH] Fix last(?) MPI memory leak for reproducible sums

---
 src/utils/ReproducibleSumMPI.hpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/utils/ReproducibleSumMPI.hpp b/src/utils/ReproducibleSumMPI.hpp
index fc49c051b..fcb9bdc1e 100644
--- a/src/utils/ReproducibleSumMPI.hpp
+++ b/src/utils/ReproducibleSumMPI.hpp
@@ -43,6 +43,7 @@ allReduceReproducibleSum(const ReproducibleScalarSum<ArrayT, BoolArrayT>& s)
   BinType sum_bin = zero;
   MPI_Allreduce(&local_bin, &sum_bin, 1, mpi_bin_type, mpi_bin_sum_op, parallel::Messenger::getInstance().comm());
 
+  MPI_Type_free(&mpi_bin_type);
   MPI_Op_free(&mpi_bin_sum_op);
 
   return sum_bin;
@@ -71,6 +72,7 @@ allReduceReproducibleSum(const ReproducibleTinyVectorSum<ArrayT, BoolArrayT>& s)
   MPI_Allreduce(&local_bin, &sum_bin, 1, mpi_bin_type, mpi_bin_sum_op, parallel::Messenger::getInstance().comm());
 
   MPI_Op_free(&mpi_bin_sum_op);
+  MPI_Type_free(&mpi_bin_type);
 
   return sum_bin;
 }
@@ -98,6 +100,7 @@ allReduceReproducibleSum(const ReproducibleTinyMatrixSum<ArrayT, BoolArrayT>& s)
   MPI_Allreduce(&local_bin, &sum_bin, 1, mpi_bin_type, mpi_bin_sum_op, parallel::Messenger::getInstance().comm());
 
   MPI_Op_free(&mpi_bin_sum_op);
+  MPI_Type_free(&mpi_bin_type);
 
   return sum_bin;
 }
-- 
GitLab