Memory leak in RecursiveInterface?
Given code
/// @brief Whether particle p originate from any of the ptcls
bool originateFrom(const Particle &p, const Particles &ptcls)
{
ConstGenVertexPtr prodVtx = p.genParticle()->production_vertex();
if (prodVtx == nullptr)
return false;
// for each ancestor, check if it matches any of the input particles
for (auto ancestor : Rivet::HepMCUtils::particles(prodVtx, HepMC3::Ancestors()))
{
for (auto part : ptcls)
if (ancestor == part.genParticle())
return true;
}
// if we get here, no ancetor matched any input particle
return false;
}
from some Rivet Higgs Cross Section Working Group analysis one runs into heavy memory usage. I presume the issue comes from here https://gitlab.cern.ch/hepmc/HepMC3/-/blob/254c5f4fb9d7a3d7c6c04f3508d5cbbaeac6e707/search/include/HepMC3/Relatives.h#L261 where the new operator is used and the corresponding delete only gets used in the operator call https://gitlab.cern.ch/hepmc/HepMC3/-/blob/254c5f4fb9d7a3d7c6c04f3508d5cbbaeac6e707/search/include/HepMC3/Relatives.h#L241.
IMO the delete loop should be in a destructor, such that at the end of above originateFrom
function the values get deleted, or am I missing something?
Best, APN
Edited by Alexander Puck Neuwirth