MemoryAuditor Class Reference

Monitors the memory use of each algorithm. More...

#include <src/MemoryAuditor.h>

Inheritance diagram for MemoryAuditor:
Collaboration diagram for MemoryAuditor:

Public Member Functions

 MemoryAuditor (const std::string &name, ISvcLocator *pSvcLocator)
 
- Public Member Functions inherited from CommonAuditor
 CommonAuditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
virtual ~CommonAuditor ()=default
 Destructor. More...
 
virtual void before (StandardEventType evt, const std::string &caller)
 
virtual void before (StandardEventType evt, INamedInterface *caller)
 
virtual void before (CustomEventTypeRef evt, const std::string &caller)
 
virtual void before (CustomEventTypeRef evt, INamedInterface *caller)
 
virtual void after (StandardEventType evt, const std::string &caller, const StatusCode &sc)
 
virtual void after (StandardEventType evt, INamedInterface *caller, const StatusCode &sc)
 
virtual void after (CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc)
 
virtual void after (CustomEventTypeRef evt, INamedInterface *caller, const StatusCode &sc)
 
- Public Member Functions inherited from Auditor
 Auditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
 ~Auditor () override=default
 Destructor. More...
 
StatusCode sysInitialize ()
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize ()
 Finalization method invoked by the framework. More...
 
void before (StandardEventType, INamedInterface *) override
 The following methods are meant to be implemented by the child class... More...
 
void before (StandardEventType, const std::string &) override
 
void before (CustomEventTypeRef, INamedInterface *) override
 
void before (CustomEventTypeRef, const std::string &) override
 
void after (StandardEventType, INamedInterface *, const StatusCode &) override
 
void after (StandardEventType, const std::string &, const StatusCode &) override
 
void after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
 
void after (CustomEventTypeRef, const std::string &, const StatusCode &) override
 
void beforeInitialize (INamedInterface *) override
 
void afterInitialize (INamedInterface *) override
 
void beforeReinitialize (INamedInterface *) override
 
void afterReinitialize (INamedInterface *) override
 
void beforeExecute (INamedInterface *) override
 
void afterExecute (INamedInterface *, const StatusCode &) override
 
void beforeFinalize (INamedInterface *) override
 
void afterFinalize (INamedInterface *) override
 
void beforeBeginRun (INamedInterface *) override
 
void afterBeginRun (INamedInterface *) override
 
void beforeEndRun (INamedInterface *) override
 
void afterEndRun (INamedInterface *) override
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
const std::string & name () const override
 
bool isEnabled () const override
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
int outputLevel () const
 Retrieve the output level of current auditor. More...
 
void setOutputLevel (int level)
 Set the output level for current auditor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 The standard service locator. More...
 
template<class T >
StatusCode service (const std::string &name, T *&svc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T = IService>
SmartIF< T > service (const std::string &name, bool createIf=false) const
 
StatusCode setProperty (const Property &p) override
 Set a value of a property of an auditor. More...
 
StatusCode setProperty (const std::string &s) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 Implementation of IProperty::setProperty. More...
 
StatusCode getProperty (Property *p) const override
 Get the value of a property. More...
 
const PropertygetProperty (const std::string &name) const override
 Get the property by name. More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 Implementation of IProperty::getProperty. More...
 
const std::vector< Property * > & getProperties () const
 Get all properties. More...
 
bool hasProperty (const std::string &name) const override
 Implementation of IProperty::hasProperty. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setProperties ()
 Set the auditor's properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
 Auditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
 ~Auditor () override=default
 Destructor. More...
 
StatusCode sysInitialize ()
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize ()
 Finalization method invoked by the framework. More...
 
void before (StandardEventType, INamedInterface *) override
 The following methods are meant to be implemented by the child class... More...
 
void before (StandardEventType, const std::string &) override
 
void before (CustomEventTypeRef, INamedInterface *) override
 
void before (CustomEventTypeRef, const std::string &) override
 
void after (StandardEventType, INamedInterface *, const StatusCode &) override
 
void after (StandardEventType, const std::string &, const StatusCode &) override
 
void after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
 
void after (CustomEventTypeRef, const std::string &, const StatusCode &) override
 
void beforeInitialize (INamedInterface *) override
 
void afterInitialize (INamedInterface *) override
 
void beforeReinitialize (INamedInterface *) override
 
void afterReinitialize (INamedInterface *) override
 
void beforeExecute (INamedInterface *) override
 
void afterExecute (INamedInterface *, const StatusCode &) override
 
void beforeFinalize (INamedInterface *) override
 
void afterFinalize (INamedInterface *) override
 
void beforeBeginRun (INamedInterface *) override
 
void afterBeginRun (INamedInterface *) override
 
void beforeEndRun (INamedInterface *) override
 
void afterEndRun (INamedInterface *) override
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
const std::string & name () const override
 
bool isEnabled () const override
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
int outputLevel () const
 Retrieve the output level of current auditor. More...
 
void setOutputLevel (int level)
 Set the output level for current auditor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 The standard service locator. More...
 
template<class T >
StatusCode service (const std::string &name, T *&svc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T = IService>
SmartIF< T > service (const std::string &name, bool createIf=false) const
 
StatusCode setProperty (const Property &p) override
 Set a value of a property of an auditor. More...
 
StatusCode setProperty (const std::string &s) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 Implementation of IProperty::setProperty. More...
 
StatusCode getProperty (Property *p) const override
 Get the value of a property. More...
 
const PropertygetProperty (const std::string &name) const override
 Get the property by name. More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 Implementation of IProperty::getProperty. More...
 
const std::vector< Property * > & getProperties () const
 Get all properties. More...
 
bool hasProperty (const std::string &name) const override
 Implementation of IProperty::hasProperty. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setProperties ()
 Set the auditor's properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
- Public Member Functions inherited from implements< Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
 ~implements () override=default
 Virtual destructor. More...
 
unsigned long addRef () override
 Reference Interface instance. More...
 
unsigned long release () override
 Release Interface instance. More...
 
unsigned long refCount () const override
 Current reference count. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
 ~implements () override=default
 Virtual destructor. More...
 
unsigned long addRef () override
 Reference Interface instance. More...
 
unsigned long release () override
 Release Interface instance. More...
 
unsigned long refCount () const override
 Current reference count. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Member Functions

virtual void i_before (CustomEventTypeRef evt, const std::string &caller)
 Default (catch-all) "before" Auditor hook. More...
 
virtual void i_after (CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc)
 Default (catch-all) "after" Auditor hook. More...
 
virtual void i_printinfo (const std::string &msg, CustomEventTypeRef evt, const std::string &caller)
 Report the memory usage. More...
 
- Protected Member Functions inherited from CommonAuditor
bool i_auditEventType (const std::string &evt)
 Check if we are requested to audit the passed event type. More...
 
void i_updateCustomTypes (Property &)
 Update handler for the obsolete property CustomEventTypes. More...
 

Static Protected Member Functions

static bool getProcInfo (procInfo &info)
 Get the process informations. More...
 

Additional Inherited Members

- Public Types inherited from Auditor
typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
 
typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from implements< Interfaces >
using base_class = implements< Interfaces...>
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
using base_class = implements< Interfaces...>
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Attributes inherited from CommonAuditor
StringArrayProperty m_types
 
StringArrayProperty m_customTypes
 
- Protected Attributes inherited from implements< Interfaces >
unsigned long m_refCount = 0
 Reference counter. More...
 

Detailed Description

Monitors the memory use of each algorithm.

Author
M. Shapiro, LBNL
Marco Clemencic

Definition at line 11 of file MemoryAuditor.h.

Constructor & Destructor Documentation

MemoryAuditor::MemoryAuditor ( const std::string &  name,
ISvcLocator pSvcLocator 
)

Definition at line 15 of file MemoryAuditor.cpp.

16 : CommonAuditor(name, pSvcLocator) {
17 }
const std::string & name() const override
Definition: Auditor.cpp:212
CommonAuditor(const std::string &name, ISvcLocator *svcloc)
Constructor.

Member Function Documentation

static bool MemoryAuditor::getProcInfo ( procInfo info)
inlinestaticprotected

Get the process informations.

Returns true if it was possible to retrieve the informations.

Definition at line 27 of file MemoryAuditor.h.

27  {
28  return ProcStats::instance()->fetch(info);
29  }
static ProcStats * instance()
Definition: ProcStats.cpp:237
bool fetch(procInfo &fill_me)
Definition: ProcStats.cpp:263
void MemoryAuditor::i_after ( CustomEventTypeRef  evt,
const std::string &  caller,
const StatusCode sc 
)
protectedvirtual

Default (catch-all) "after" Auditor hook.

Implements CommonAuditor.

Definition at line 23 of file MemoryAuditor.cpp.

23  {
24  i_printinfo("Memory usage has changed after", evt, caller);
25 }
virtual void i_printinfo(const std::string &msg, CustomEventTypeRef evt, const std::string &caller)
Report the memory usage.
void MemoryAuditor::i_before ( CustomEventTypeRef  evt,
const std::string &  caller 
)
protectedvirtual

Default (catch-all) "before" Auditor hook.

Implements CommonAuditor.

Reimplemented in MemStatAuditor.

Definition at line 19 of file MemoryAuditor.cpp.

19  {
20  i_printinfo("Memory usage before", evt, caller);
21 }
virtual void i_printinfo(const std::string &msg, CustomEventTypeRef evt, const std::string &caller)
Report the memory usage.
void MemoryAuditor::i_printinfo ( const std::string &  msg,
CustomEventTypeRef  evt,
const std::string &  caller 
)
protectedvirtual

Report the memory usage.

Reimplemented in MemStatAuditor.

Definition at line 27 of file MemoryAuditor.cpp.

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
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:220
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
double rss
Definition: ProcStats.h:38
static bool getProcInfo(procInfo &info)
Get the process informations.
Definition: MemoryAuditor.h:27
const std::string & name() const override
Definition: Auditor.cpp:212
double vsize
Definition: ProcStats.h:37

The documentation for this class was generated from the following files: