From e4ffbb1f1540326817ee080231d6f699efa3c4b5 Mon Sep 17 00:00:00 2001 From: Oliver Sander <oliver.sander@tu-dresden.de> Date: Wed, 29 Jan 2025 11:33:45 +0100 Subject: [PATCH] Fix memory leak in the CHOLMOD wrapper code When calling CHOLMOD to compute the Cholesky factor of a matrix, it was not tested whether such a factor already existed. As a consequence, if the solver was called twice in a row, the old factor would be lost to a memory leak. Fix this by explicitly deallocating the old Cholesky factor before asking CHOLMOD for a new one. --- dune/istl/cholmod.hh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dune/istl/cholmod.hh b/dune/istl/cholmod.hh index bfc8457a2..a69de4b27 100644 --- a/dune/istl/cholmod.hh +++ b/dune/istl/cholmod.hh @@ -461,6 +461,10 @@ public: }); + // Remove old factor that may be left over from a previous run + if (L_) + CholmodMethod::free_factor(&L_, &c_); + // Now analyse the pattern and optimal row order L_ = CholmodMethod::analyze(M.get(), &c_); -- GitLab