haskell-numerics / hmatrix

Linear algebra and numerical computation
381 stars 104 forks source link

GSL.ODE: free the jacobian after use #250

Closed thufschmitt closed 6 years ago

thufschmitt commented 6 years ago

When calling the function Numeric.GSL.ODE.odeSolveVWith' and provide a jacobian, a pointer to this jacobian is registered, but never freed, which causes a memory leak.

https://github.com/albertoruiz/hmatrix/blob/8cb879a4ad83656bc70652957a08113e2b784886/packages/gsl/src/Numeric/GSL/ODE.hs#L146-L148 This PR adds a call to freeHaskellFunPtr when needed at the end of the function to fix this.