From 594a77198f154de54f5aa3395b22b2536a9ecc4c Mon Sep 17 00:00:00 2001 From: regnat Date: Wed, 7 Feb 2018 14:51:38 +0100 Subject: GSL.ODE: free the jacobian after use When calling the function `Numeric.GSL.ODE.odeSolveVWith'` and provide a jacobian, a pointer to this jacobian is registered (at https://github.com/albertoruiz/hmatrix/blob/8cb879a4ad83656bc70652957a08113e2b784886/packages/gsl/src/Numeric/GSL/ODE.hs#L146-L148), but never freed, which causes a memory leak. This commits adds a call to `freeHaskellFunPtr` when needed at the end of the function to fix this. --- packages/gsl/src/Numeric/GSL/ODE.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/gsl/src/Numeric/GSL/ODE.hs') diff --git a/packages/gsl/src/Numeric/GSL/ODE.hs b/packages/gsl/src/Numeric/GSL/ODE.hs index c4fab85..987d47e 100644 --- a/packages/gsl/src/Numeric/GSL/ODE.hs +++ b/packages/gsl/src/Numeric/GSL/ODE.hs @@ -152,6 +152,7 @@ odeSolveVWith' method mbjac control epsAbs epsRel aX aX' mbsc h f xiv ts = // sc' // xiv' // ts' ) "ode" freeHaskellFunPtr fp + if (jp /= nullFunPtr) then freeHaskellFunPtr jp else pure () return sol foreign import ccall safe "ode" -- cgit v1.2.3