Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #25298; memory leak fix for HepPDT::HeavyIonUnknownID #32671

Merged
merged 1 commit into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion SimGeneral/HepPDTESSource/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<use name="SimGeneral/HepPDTRecord"/>
<use name="tbb"/>
<use name="heppdt"/>
<flags EDM_PLUGIN="1"/>
23 changes: 1 addition & 22 deletions SimGeneral/HepPDTESSource/src/HepPDTESSource.cc
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
#include "HepPDT/HeavyIonUnknownID.hh"
#include "SimGeneral/HepPDTESSource/interface/HepPDTESSource.h"
#include "tbb/concurrent_vector.h"

namespace {

class CachingHeavyIonUnknownID : public HepPDT::ProcessUnknownID {
HepPDT::ParticleData *processUnknownID(HepPDT::ParticleID id, const HepPDT::ParticleDataTable &table) final {
// HeavyIonUnknownID constructs a new particle but does not delete it
// we need to do that ourselves
std::unique_ptr<HepPDT::ParticleData> p{wrapped_.processUnknownID(id, table)};
auto *pPtr = p.get();
if (p) {
particles_.emplace_back(std::move(p));
}
return pPtr;
}

HepPDT::HeavyIonUnknownID wrapped_;
tbb::concurrent_vector<std::unique_ptr<HepPDT::ParticleData>> particles_;
};

} // namespace

HepPDTESSource::HepPDTESSource(const edm::ParameterSet &cfg)
: pdtFileName(cfg.getParameter<edm::FileInPath>("pdtFileName")) {
Expand All @@ -32,7 +11,7 @@ HepPDTESSource::~HepPDTESSource() {}

HepPDTESSource::ReturnType HepPDTESSource::produce(const PDTRecord &iRecord) {
using namespace edm::es;
auto pdt = std::make_unique<PDT>("PDG table", new CachingHeavyIonUnknownID);
auto pdt = std::make_unique<PDT>("PDG table", new HepPDT::HeavyIonUnknownID);
std::ifstream pdtFile(pdtFileName.fullPath().c_str());
if (!pdtFile)
throw cms::Exception("FileNotFound", "can't open pdt file") << "cannot open " << pdtFileName.fullPath();
Expand Down