| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MemStatAuditor.cpp
Go to the documentation of this file.
1 #ifdef __ICC
2 // disable icc warning #654: overloaded virtual function "B::Y" is only partially overridden in class "C"
3 // TODO: there is only a partial overload of IAuditor::before and IAuditor::after
4 #pragma warning(disable:654)
5 #endif
6
7 #include "GaudiKernel/MsgStream.h"
8 #include "GaudiKernel/IChronoStatSvc.h"
9
10 #include "GaudiKernel/Stat.h"
11
13 #include "ProcStats.h"
14 #include "MemStatAuditor.h"
15
16 DECLARE_COMPONENT(MemStatAuditor)
17
18 MemStatAuditor::MemStatAuditor(const std::string& name, ISvcLocator* pSvcLocator) :
19 MemoryAuditor(name, pSvcLocator), m_vSize(-1.)
20 {
21 }
22
23 MemStatAuditor::~MemStatAuditor() {}
24
25 StatusCode MemStatAuditor::initialize() {
26 StatusCode sc = CommonAuditor::initialize();
27 if (UNLIKELY(sc.isFailure())) return sc;
28
29 m_stat = serviceLocator()->service("ChronoStatSvc");
30 if (UNLIKELY(!m_stat.get())) {
31 MsgStream log(msgSvc(), name());
32 log << MSG::ERROR << "Cannot get ChronoStatSvc" << endmsg;
33 return StatusCode::FAILURE;
34 }
35 return StatusCode::SUCCESS;
36 }
37
38 void MemStatAuditor::i_before(CustomEventTypeRef /*evt*/, const std::string& /*caller*/) {
39 // It's not interesting to monitor the memory usage before the methods.
40 }
41
42 void MemStatAuditor::i_printinfo(const std::string& msg, CustomEventTypeRef evt, const std::string& caller) {
43 // cannot be exactly 0
44 double deltaVSize = 0.00001;
45
46 procInfo info;
47 if (getProcInfo(info)) {
48 MsgStream log(msgSvc(), name());
49
50 if (info.vsize > 0) {
51 if (m_vSize > 0){
52 deltaVSize = info.vsize - m_vSize;
53 }
54 // store the current VSize to be able to monitor the increment
55 m_vSize = info.vsize;
56 }
57
58 log << MSG::INFO << msg << " " << caller << " " << evt <<
59 " \tvirtual size = " << info.vsize << " MB" <<
60 " \tresident set size = " << info.rss << " MB" <<
61 " deltaVsize = " << deltaVSize << " MB" << endmsg;
62 }
63 // fill the stat for every call, not just when there is a change
64 // only monitor the increment in VSize
65 // Stat stv(statSvc(), caller + ":VMemUsage", info.vsize);
66 // Stat str(statSvc(), caller + ":RMemUsage", info.rss);
67 Stat sts(statSvc(), caller + ":VMem", deltaVSize);
68 }