[Numerics] Fix memory leak in CVodesIntegrator
Memory allocated in CVodesIntegrator::sensInit was not being released.
This commit is contained in:
parent
032bb9c363
commit
cd77a94588
1 changed files with 5 additions and 0 deletions
|
|
@ -89,6 +89,7 @@ CVodesIntegrator::CVodesIntegrator() :
|
|||
m_hmin(0.0),
|
||||
m_maxsteps(20000),
|
||||
m_maxErrTestFails(0),
|
||||
m_yS(nullptr),
|
||||
m_np(0),
|
||||
m_mupper(0), m_mlower(0),
|
||||
m_sens_ok(false)
|
||||
|
|
@ -109,6 +110,9 @@ CVodesIntegrator::~CVodesIntegrator()
|
|||
if (m_abstol) {
|
||||
N_VDestroy_Serial(m_abstol);
|
||||
}
|
||||
if (m_yS) {
|
||||
N_VDestroyVectorArray_Serial(m_yS, m_np);
|
||||
}
|
||||
}
|
||||
|
||||
double& CVodesIntegrator::solution(size_t k)
|
||||
|
|
@ -219,6 +223,7 @@ void CVodesIntegrator::sensInit(double t0, FuncEval& func)
|
|||
for (size_t n = 0; n < m_np; n++) {
|
||||
N_VConst(0.0, m_yS[n]);
|
||||
}
|
||||
N_VDestroy_Serial(y);
|
||||
|
||||
int flag = CVodeSensInit(m_cvode_mem, static_cast<sd_size_t>(m_np),
|
||||
CV_STAGGERED, CVSensRhsFn(0), m_yS);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue