LLNL / sundials

Official development repository for SUNDIALS - a SUite of Nonlinear and DIfferential/ALgebraic equation Solvers. Pull requests are welcome for bug fixes and minor changes.
https://computing.llnl.gov/projects/sundials
BSD 3-Clause "New" or "Revised" License
522 stars 130 forks source link

ARKODE Stepper SetDefaults memory leak fix #560

Closed drreynolds closed 2 months ago

drreynolds commented 3 months ago

Updated stepper SetDefaults routines to deallocate pre-existing structures before nullifying, and moved initial creation of the SUNAdaptController into stepper SetDefaults routines instead of arkCreate. This allows non-adaptive steppers to leave the SUNAdaptController object unallocated.

drreynolds commented 2 months ago

Other than the minor suggestion to remove an erroneous new line, do arkPrintAdaptMem and arkAdapt also need checks for a NULL controller?

The NULL check was indeed necessary in arkPrintAdaptMem. I added it to arkAdapt as well just in case, but since any non-adaptive stepper (who leaves a NULL-valued SUNAdaptController) must also set ark_mem->fixedstep to SUNTRUE, that check should be redundant.