Skip to content

Commit

Permalink
fix memory leak from missing destructor in Sampler (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
acavelan authored Jan 21, 2025
1 parent 60ae7d4 commit a912158
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
15 changes: 9 additions & 6 deletions model/Transmission/PerHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ class HumanVectorInterventionComponent;
* Parameters are read from XML, and the availability rate is adjusted. */
class PerHostAnophParams {
public:
static inline void initReserve (size_t numSpecies) {
params.reserve (numSpecies);
}
PerHostAnophParams (const scnXml::Mosq& mosq);

PerHostAnophParams(PerHostAnophParams&&) noexcept = default;
PerHostAnophParams& operator=(PerHostAnophParams&&) noexcept = default;

PerHostAnophParams(const PerHostAnophParams&) = delete;
PerHostAnophParams& operator=(const PerHostAnophParams&) = delete;

static inline void init (const scnXml::Mosq& mosq) {
params.push_back(PerHostAnophParams{ mosq });
params.emplace_back(mosq);
}

/// Get the number of vector species
Expand Down Expand Up @@ -133,8 +138,6 @@ class PerHostAnophParams {
//@}

private:
PerHostAnophParams (const scnXml::Mosq& mosq);

static vector<PerHostAnophParams> params;
static vector<double> entoAvailabilityPercentiles;

Expand Down
2 changes: 0 additions & 2 deletions model/Transmission/transmission.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,6 @@ inline VectorModel *createVectorModel(const scnXml::Entomology &entoData, int po
// Sort Anopheles by Decreasing EIR
sort(anophelesList.begin(), anophelesList.end(), anophelesCompare);

PerHostAnophParams::initReserve(numSpecies);

for (size_t i = 0; i < numSpecies; ++i)
{
auto anoph = anophelesList[i];
Expand Down
1 change: 1 addition & 0 deletions model/util/sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace OM { namespace util {
class Sampler
{
public:
virtual ~Sampler() = default;
virtual double sample(LocalRng& rng) const = 0;
virtual void scaleMean( double scalar ) = 0;
virtual double mean() const = 0;
Expand Down

0 comments on commit a912158

Please sign in to comment.