Skip to content

Commit 6dfd41f

Browse files
authored
Fix memory deallocation with correct SUNDIALS function calls (#1364)
1 parent 6f184d5 commit 6dfd41f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/OMSimulatorLib/SystemSC.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ oms_status_enu_t oms::SystemSC::terminate()
455455
logInfo(msg);
456456

457457
SUNMatDestroy(solverData.cvode.J);
458-
N_VDestroy(solverData.cvode.liny);
458+
N_VDestroy_Serial(solverData.cvode.liny);
459459
SUNLinSolFree(solverData.cvode.linSol);
460460
N_VDestroy_Serial(solverData.cvode.y);
461461
N_VDestroy_Serial(solverData.cvode.abstol);
@@ -521,6 +521,9 @@ oms_status_enu_t oms::SystemSC::reset()
521521
msg += "NumNonlinSolvIters = " + std::to_string(nni) + " NumNonlinSolvConvFails = " + std::to_string(ncfn) + " NumErrTestFails = " + std::to_string(netf);
522522
logInfo(msg);
523523

524+
SUNMatDestroy(solverData.cvode.J);
525+
N_VDestroy_Serial(solverData.cvode.liny);
526+
SUNLinSolFree(solverData.cvode.linSol);
524527
N_VDestroy_Serial(solverData.cvode.y);
525528
N_VDestroy_Serial(solverData.cvode.abstol);
526529
CVodeFree(&(solverData.cvode.mem));

0 commit comments

Comments
 (0)