From bdfd19d3fe6ebee29d42770d4560ec9a4a0610ab Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 12 Apr 2024 10:53:51 -0500 Subject: [PATCH] Fix memory use when writing ParameterSets to files When forwarding a VPSet from the input file to the output, avoid calling vpset() which triggers creating the entire vector. --- FWCore/ParameterSet/src/ParameterSet.cc | 2 +- FWCore/ParameterSet/src/VParameterSetEntry.cc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/FWCore/ParameterSet/src/ParameterSet.cc b/FWCore/ParameterSet/src/ParameterSet.cc index d22f363866c40..9909c239fda81 100644 --- a/FWCore/ParameterSet/src/ParameterSet.cc +++ b/FWCore/ParameterSet/src/ParameterSet.cc @@ -507,7 +507,7 @@ namespace edm { if (useAll || b->second.isTracked()) { size += 2; size += b->first.size(); - size += sizeof(ParameterSetID) * b->second.vpset().size(); + size += sizeof(ParameterSetID) * b->second.size(); } } diff --git a/FWCore/ParameterSet/src/VParameterSetEntry.cc b/FWCore/ParameterSet/src/VParameterSetEntry.cc index 79fdc007cbcaf..7f464a95cb75e 100644 --- a/FWCore/ParameterSet/src/VParameterSetEntry.cc +++ b/FWCore/ParameterSet/src/VParameterSetEntry.cc @@ -102,7 +102,9 @@ namespace edm { return theVPSet_->at(i); } - std::vector::size_type VParameterSetEntry::size() const { return vpset().size(); } + std::vector::size_type VParameterSetEntry::size() const { + return theIDs_ ? theIDs_->size() : (theVPSet_ ? vpset().size() : 0); + } void VParameterSetEntry::registerPsetsAndUpdateIDs() { fillVPSet();