ATLAS Offline Software
SegMemSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "StoreGate/SegMemSvc.h"
6 
7 #include "GaudiKernel/ISvcLocator.h"
8 #include "GaudiKernel/IIncidentSvc.h"
9 #include "GaudiKernel/Incident.h"
10 
11 using namespace std;
12 
13 
14 //
16 //
17 
18 SegMemSvc::SegMemSvc( const std::string& name, ISvcLocator* svc )
19  : Service( name, svc ), p_incSvc("IncidentSvc",name),
20  m_arena_job("sms_job",&m_ahead_job),
21  m_arena_evt("sms_evt",&m_ahead_evt),
22  m_arena_inc("sms_inc",&m_ahead_inc)
23 {
24 
25 }
26 
27 
28 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
29 
31 
32 }
33 
34 
35 StatusCode SegMemSvc::queryInterface( const InterfaceID& riid,
36  void** ppvInterface ) {
37  StatusCode sc = StatusCode::FAILURE;
38  if ( ppvInterface ) {
39  *ppvInterface = 0;
40 
41  if ( SegMemSvc::interfaceID().versionMatch(riid) ) {
42  *ppvInterface = static_cast<SegMemSvc*>(this);
43  sc = StatusCode::SUCCESS;
44  addRef();
45  }
46  else
47  sc = Service::queryInterface( riid, ppvInterface );
48  }
49  return sc;
50 }
51 
52 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
53 
56 
60 
61  // m_ahead.addArena(&m_arena);
62 
63 
64  p_incSvc->addListener( this, "EndEvent" );
65  p_incSvc->addListener( this, "DefragMemory" );
66 
67  return StatusCode::SUCCESS;
68 
69 }
70 
71 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
72 
75 
76  return StatusCode::SUCCESS;
77 
78 }
79 
80 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
81 
84 
85  return StatusCode::SUCCESS;
86 
87 }
88 
89 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
90 
91 void
92 SegMemSvc::handle(const Incident& inc) {
93 
94  if (inc.type() == "EndEvent") {
95  if (msgStream().level() <= MSG::DEBUG) {
96  std::ostringstream ost;
98  debug() << "Running report for " << m_arena_evt.name()
99  << ost.str() << endmsg;
100  }
101 
102  debug() << "freeing all memory allocated for Event" << endmsg;
103  m_arena_evt.reset();
104  m_ahead_evt.reset();
105 
106  } else if ( inc.type() == "DefragMemory") {
107 
108  if (msgStream().level() <= MSG::DEBUG) {
109  debug() << "defragmenting memory" << endmsg;
110  }
111  debug() << "freeing all memory allocated associated with "
112  << "DefragMemory incident" << endmsg;
113  m_arena_inc.reset();
114  m_ahead_inc.reset();
115  }
116 
117 }
118 
SegMemSvc::reinitialize
virtual StatusCode reinitialize()
Definition: SegMemSvc.cxx:74
SegMemSvc::~SegMemSvc
virtual ~SegMemSvc()
Definition: SegMemSvc.cxx:30
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
SegMemSvc::m_arena_inc
SG::Arena m_arena_inc
Definition: SegMemSvc.h:100
python.FakeAthena.Service
def Service(name)
Definition: FakeAthena.py:38
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SegMemSvc::m_ahead_inc
SG::ArenaHeader m_ahead_inc
Definition: SegMemSvc.h:99
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
SG::ArenaHeader::report
void report(std::ostream &os) const
Generate a report of all Arenas in the group.
Definition: ArenaHeader.cxx:115
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::ArenaBase::reset
void reset()
Reset all contained allocators.
Definition: ArenaBase.cxx:44
SG::ArenaHeader::reset
void reset()
Call reset on all Allocators in the current Arena.
Definition: ArenaHeader.cxx:153
SegMemSvc::m_ahead_evt
SG::ArenaHeader m_ahead_evt
Definition: SegMemSvc.h:99
SegMemSvc::m_arena_evt
SG::Arena m_arena_evt
Definition: SegMemSvc.h:100
SegMemSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: SegMemSvc.h:50
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
SegMemSvc::handle
virtual void handle(const Incident &)
Definition: SegMemSvc.cxx:92
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
SegMemSvc
Service to access an arena caching allocator.
Definition: SegMemSvc.h:30
SegMemSvc::m_arena_job
SG::Arena m_arena_job
Definition: SegMemSvc.h:100
SegMemSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
Definition: SegMemSvc.cxx:35
SegMemSvc::SegMemSvc
SegMemSvc(const std::string &name, ISvcLocator *svc)
Definition: SegMemSvc.cxx:18
DEBUG
#define DEBUG
Definition: page_access.h:11
SegMemSvc.h
SegMemSvc::p_incSvc
ServiceHandle< IIncidentSvc > p_incSvc
Definition: SegMemSvc.h:86
SegMemSvc::finalize
virtual StatusCode finalize()
Definition: SegMemSvc.cxx:83
SegMemSvc::initialize
virtual StatusCode initialize()
Definition: SegMemSvc.cxx:55
SG::ArenaBase::name
const std::string & name() const
Return this Arena's name.
Definition: ArenaBase.cxx:114
SG::Arena::Push
Helper class for making Arena instances current in a stack-like manner.
Definition: Arena.h:273