All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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)
16 : CommonAuditor(name, pSvcLocator) {
17 }
18 
19 void MemoryAuditor::i_before(CustomEventTypeRef evt, const std::string& caller) {
20  i_printinfo("Memory usage before", evt, caller);
21 }
22 
23 void MemoryAuditor::i_after(CustomEventTypeRef evt, const std::string& caller, const StatusCode&){
24  i_printinfo("Memory usage has changed after", evt, caller);
25 }
26 
27 void MemoryAuditor::i_printinfo(const std::string& msg, CustomEventTypeRef evt, const std::string& caller)
28 {
29  procInfo info;
30  // The fetch method returns true if memory usage has changed...
31  if(getProcInfo(info)) {
32  MsgStream log(msgSvc(), name());
33  log << MSG::INFO << msg << " " << caller << " " << evt <<
34  " virtual size = " << info.vsize << " MB" <<
35  " resident set size = " << info.rss << " MB" << endmsg;
36  }
37 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
virtual const std::string & name() const
Retrieve the name of the instance.
Definition: Auditor.cpp:218
virtual void i_before(CustomEventTypeRef evt, const std::string &caller)
Default (catch-all) "before" Auditor hook.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:226
Base class with common functionalities shared by few auditor implementations.
Definition: CommonAuditor.h:5
const CustomEventType & CustomEventTypeRef
Used in function calls for optimization purposes.
Definition: IAuditor.h:41
virtual void i_printinfo(const std::string &msg, CustomEventTypeRef evt, const std::string &caller)
Report the memory usage.
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
double rss
Definition: ProcStats.h:34
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
static bool getProcInfo(procInfo &info)
Get the process informations.
Definition: MemoryAuditor.h:27
Monitors the memory use of each algorithm.
Definition: MemoryAuditor.h:11
double vsize
Definition: ProcStats.h:33
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual void i_after(CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc)
Default (catch-all) "after" Auditor hook.