Skip to content

Commit

Permalink
[Numerics] Fix memory leak in CVodesIntegrator
Browse files Browse the repository at this point in the history
Memory allocated in CVodesIntegrator::sensInit was not being released.
  • Loading branch information
speth committed Apr 20, 2016
1 parent 032bb9c commit cd77a94
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/numerics/CVodesIntegrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit cd77a94

Please sign in to comment.