diff --git a/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h b/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h index 1bb532737f2d7..752a54743282c 100644 --- a/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h +++ b/FWCore/Framework/interface/stream/EDAnalyzerAdaptor.h @@ -65,7 +65,7 @@ namespace edm { } EDAnalyzerAdaptor(const EDAnalyzerAdaptor&) = delete; // stop default const EDAnalyzerAdaptor& operator=(const EDAnalyzerAdaptor&) = delete; // stop default - ~EDAnalyzerAdaptor() override {} + ~EDAnalyzerAdaptor() override { deleteModulesEarly(); } static void fillDescriptions(ConfigurationDescriptions& descriptions) { T::fillDescriptions(descriptions); } static void prevalidate(ConfigurationDescriptions& descriptions) { T::prevalidate(descriptions); } diff --git a/FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h b/FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h index 95ec3a1a268f3..9f1d4c4794f21 100644 --- a/FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h +++ b/FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h @@ -126,6 +126,8 @@ namespace edm { std::vector consumesInfo() const; + void deleteModulesEarly(); + private: bool doEvent(EventTransitionInfo const&, ActivityRegistry*, ModuleCallingContext const*); void doPreallocate(PreallocationConfiguration const&); diff --git a/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h b/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h index 499691f733430..7c8381b835f62 100644 --- a/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h +++ b/FWCore/Framework/interface/stream/ProducingModuleAdaptor.h @@ -53,7 +53,7 @@ namespace edm { } ProducingModuleAdaptor(const ProducingModuleAdaptor&) = delete; // stop default const ProducingModuleAdaptor& operator=(const ProducingModuleAdaptor&) = delete; // stop default - ~ProducingModuleAdaptor() override {} + ~ProducingModuleAdaptor() override { this->deleteModulesEarly(); } static void fillDescriptions(ConfigurationDescriptions& descriptions) { T::fillDescriptions(descriptions); } static void prevalidate(ConfigurationDescriptions& descriptions) { T::prevalidate(descriptions); } diff --git a/FWCore/Framework/interface/stream/ProducingModuleAdaptorBase.h b/FWCore/Framework/interface/stream/ProducingModuleAdaptorBase.h index 2171e04ab8ba4..5c51a76ff5590 100644 --- a/FWCore/Framework/interface/stream/ProducingModuleAdaptorBase.h +++ b/FWCore/Framework/interface/stream/ProducingModuleAdaptorBase.h @@ -149,6 +149,8 @@ namespace edm { const ProducerBase* producer() { return m_streamModules[0]; } + void deleteModulesEarly(); + private: void doPreallocate(PreallocationConfiguration const&); virtual void preallocLumis(unsigned int) {} diff --git a/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc b/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc index 2cff309ee689c..813d520f252e1 100644 --- a/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc +++ b/FWCore/Framework/src/stream/EDAnalyzerAdaptorBase.cc @@ -54,6 +54,13 @@ EDAnalyzerAdaptorBase::~EDAnalyzerAdaptorBase() { } } +void EDAnalyzerAdaptorBase::deleteModulesEarly() { + for (auto m : m_streamModules) { + delete m; + } + m_streamModules.clear(); +} + // // assignment operators // diff --git a/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc b/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc index b34073bfe8425..08b90a87178d1 100644 --- a/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc +++ b/FWCore/Framework/src/stream/ProducingModuleAdaptorBase.cc @@ -47,6 +47,14 @@ namespace edm { } } + template + void ProducingModuleAdaptorBase::deleteModulesEarly() { + for (auto m : m_streamModules) { + delete m; + } + m_streamModules.clear(); + } + // // member functions //