From c522b1b7a974792e0a6a4285b7171a73040774c9 Mon Sep 17 00:00:00 2001
From: Axel Kohlmeyer <akohlmey@gmail.com>
Date: Wed, 4 Oct 2017 00:22:56 -0400
Subject: [PATCH] add call to fftw_cleanup() before exiting to avoid bogus leak
 reports when compiling with FFTW v3.x

---
 src/main.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/main.cpp b/src/main.cpp
index 7401183fea..82dac5af6d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,6 +22,10 @@
 #include <fenv.h>
 #endif
 
+#ifdef FFT_FFTW3
+#include <fftw3.h>
+#endif
+
 using namespace LAMMPS_NS;
 
 /* ----------------------------------------------------------------------
@@ -62,4 +66,10 @@ int main(int argc, char **argv)
 #endif
   MPI_Barrier(MPI_COMM_WORLD);
   MPI_Finalize();
+
+#ifdef FFT_FFTW3
+  // tell fftw3 to delete its global memory pool
+  // and thus avoid bogus valgrind memory leak reports
+  fftw_cleanup();
+#endif
 }
-- 
GitLab