Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 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 
10 
11 #include "GaudiKernel/Stat.h"
12 
14 #include "ProcStats.h"
15 #include "MemStatAuditor.h"
16 
18 
19 MemStatAuditor::MemStatAuditor(const std::string& name, ISvcLocator* pSvcLocator) :
20  MemoryAuditor(name, pSvcLocator), m_vSize(-1.)
21 {
22 }
23 
25 
28  if (UNLIKELY(sc.isFailure())) return sc;
29 
30  m_stat = serviceLocator()->service("ChronoStatSvc");
31  if (UNLIKELY(!m_stat.get())) {
32  MsgStream log(msgSvc(), name());
33  log << MSG::ERROR << "Cannot get ChronoStatSvc" << endmsg;
34  return StatusCode::FAILURE;
35  }
36  return StatusCode::SUCCESS;
37 }
38 
39 void MemStatAuditor::i_before(CustomEventTypeRef /*evt*/, const std::string& /*caller*/) {
40  // It's not interesting to monitor the memory usage before the methods.
41 }
42 
43 void MemStatAuditor::i_printinfo(const std::string& msg, CustomEventTypeRef evt, const std::string& caller) {
44  // cannot be exactly 0
45  double deltaVSize = 0.00001;
46 
47  procInfo info;
48  if (getProcInfo(info)) {
49  MsgStream log(msgSvc(), name());
50 
51  if (info.vsize > 0) {
52  if (m_vSize > 0){
53  deltaVSize = info.vsize - m_vSize;
54  }
55  // store the current VSize to be able to monitor the increment
56  m_vSize = info.vsize;
57  }
58 
59  log << MSG::INFO << msg << " " << caller << " " << evt <<
60  " \tvirtual size = " << info.vsize << " MB" <<
61  " \tresident set size = " << info.rss << " MB" <<
62  " deltaVsize = " << deltaVSize << " MB" << endmsg;
63  }
64  // fill the stat for every call, not just when there is a change
65  // only monitor the increment in VSize
66  // Stat stv(statSvc(), caller + ":VMemUsage", info.vsize);
67  // Stat str(statSvc(), caller + ":RMemUsage", info.rss);
68  Stat sts(statSvc(), caller + ":VMem", deltaVSize);
69 }

Generated at Wed Dec 4 2013 14:33:07 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004