The Gaudi Framework  v33r0 (d5ea422b)
MemoryAuditor.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 // MemoryAuditor:
12 // An auditor that monitors memory usage
13 
14 #ifdef __ICC
15 // disable icc warning #654: overloaded virtual function "B::Y" is only partially overridden in class "C"
16 // TODO: there is only a partial overload of IAuditor::before and IAuditor::after
17 # pragma warning( disable : 654 )
18 #endif
19 
20 #include "MemoryAuditor.h"
21 #include "GaudiKernel/MsgStream.h"
22 
24 
25 void MemoryAuditor::i_before( CustomEventTypeRef evt, const std::string& caller ) {
26  i_printinfo( "Memory usage before", evt, caller );
27 }
28 
29 void MemoryAuditor::i_after( CustomEventTypeRef evt, const std::string& caller, const StatusCode& ) {
30  i_printinfo( "Memory usage has changed after", evt, caller );
31 }
32 
33 void MemoryAuditor::i_printinfo( const std::string& msg, CustomEventTypeRef evt, const std::string& caller ) {
34  procInfo pInfo;
35  // The fetch method returns true if memory usage has changed...
36  if ( getProcInfo( pInfo ) ) {
37  info() << msg << " " << caller << " " << evt << " virtual size = " << pInfo.vsize << " MB"
38  << " resident set size = " << pInfo.rss << " MB" << endmsg;
39  }
40 }
void i_after(CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc) override
Default (catch-all) "after" Auditor hook.
virtual void i_printinfo(const std::string &msg, CustomEventTypeRef evt, const std::string &caller)
Report the memory usage.
STL namespace.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
STL class.
#define DECLARE_COMPONENT(type)
double rss
Definition: ProcStats.h:48
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
static bool getProcInfo(procInfo &info)
Get the process informations.
Definition: MemoryAuditor.h:37
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Monitors the memory use of each algorithm.
Definition: MemoryAuditor.h:21
double vsize
Definition: ProcStats.h:47
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202