The Gaudi Framework  v29r0 (ff2e7097)
MemoryAuditor.cpp
Go to the documentation of this file.
1 // MemoryAuditor:
2 // An auditor that monitors memory usage
3 
4 #ifdef __ICC
5 // disable icc warning #654: overloaded virtual function "B::Y" is only partially overridden in class "C"
6 // TODO: there is only a partial overload of IAuditor::before and IAuditor::after
7 #pragma warning( disable : 654 )
8 #endif
9 
10 #include "MemoryAuditor.h"
11 #include "GaudiKernel/MsgStream.h"
12 
14 
15 MemoryAuditor::MemoryAuditor( const std::string& name, ISvcLocator* pSvcLocator ) : CommonAuditor( name, pSvcLocator )
16 {
17 }
18 
19 void MemoryAuditor::i_before( CustomEventTypeRef evt, const std::string& caller )
20 {
21  i_printinfo( "Memory usage before", evt, caller );
22 }
23 
24 void MemoryAuditor::i_after( CustomEventTypeRef evt, const std::string& caller, const StatusCode& )
25 {
26  i_printinfo( "Memory usage has changed after", evt, caller );
27 }
28 
29 void MemoryAuditor::i_printinfo( const std::string& msg, CustomEventTypeRef evt, const std::string& caller )
30 {
31  procInfo pInfo;
32  // The fetch method returns true if memory usage has changed...
33  if ( getProcInfo( pInfo ) ) {
34  info() << msg << " " << caller << " " << evt << " virtual size = " << pInfo.vsize << " MB"
35  << " resident set size = " << pInfo.rss << " MB" << endmsg;
36  }
37 }
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
void i_after(CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc) override
Default (catch-all) "after" Auditor hook.
Base class with common functionalities shared by few auditor implementations.
Definition: CommonAuditor.h:8
virtual void i_printinfo(const std::string &msg, CustomEventTypeRef evt, const std::string &caller)
Report the memory usage.
STL namespace.
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:33
STL class.
double rss
Definition: ProcStats.h:39
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
static bool getProcInfo(procInfo &info)
Get the process informations.
Definition: MemoryAuditor.h:28
void i_before(CustomEventTypeRef evt, const std::string &caller) override
Default (catch-all) "before" Auditor hook.
Monitors the memory use of each algorithm.
Definition: MemoryAuditor.h:11
double vsize
Definition: ProcStats.h:38
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
evt
Definition: IOTest.py:96