Gaudi Framework, version v23r2

Home   Generated: Thu Jun 28 2012

MemStatAuditor.cpp

Go to the documentation of this file.
00001 #ifdef __ICC
00002 // disable icc warning #654: overloaded virtual function "B::Y" is only partially overridden in class "C"
00003 //   TODO: there is only a partial overload of IAuditor::before and IAuditor::after
00004 #pragma warning(disable:654)
00005 #endif
00006 
00007 #include "GaudiKernel/MsgStream.h"
00008 #include "GaudiKernel/AudFactory.h"
00009 #include "GaudiKernel/IChronoStatSvc.h"
00010 
00011 #include "GaudiKernel/Stat.h"
00012 
00014 #include "ProcStats.h"
00015 #include "MemStatAuditor.h"
00016 
00017 DECLARE_AUDITOR_FACTORY(MemStatAuditor)
00018 
00019 MemStatAuditor::MemStatAuditor(const std::string& name, ISvcLocator* pSvcLocator) :
00020   MemoryAuditor(name, pSvcLocator), m_vSize(-1.)
00021 {
00022 }
00023 
00024 MemStatAuditor::~MemStatAuditor() {}
00025 
00026 StatusCode MemStatAuditor::initialize() {
00027   StatusCode sc = CommonAuditor::initialize();
00028   if (UNLIKELY(sc.isFailure())) return sc;
00029 
00030   m_stat = serviceLocator()->service("ChronoStatSvc");
00031   if (UNLIKELY(!m_stat.get())) {
00032     MsgStream log(msgSvc(), name());
00033     log << MSG::ERROR << "Cannot get ChronoStatSvc" << endmsg;
00034     return StatusCode::FAILURE;
00035   }
00036   return StatusCode::SUCCESS;
00037 }
00038 
00039 void MemStatAuditor::i_before(CustomEventTypeRef /*evt*/, const std::string& /*caller*/) {
00040   // It's not interesting to monitor the memory usage before the methods.
00041 }
00042 
00043 void MemStatAuditor::i_printinfo(const std::string& msg, CustomEventTypeRef evt, const std::string& caller) {
00044   // cannot be exactly 0
00045   double deltaVSize = 0.00001;
00046 
00047   procInfo info;
00048   if (getProcInfo(info)) {
00049     MsgStream log(msgSvc(), name());
00050 
00051     if (info.vsize > 0) {
00052       if (m_vSize > 0){
00053         deltaVSize = info.vsize - m_vSize;
00054       }
00055       // store the current VSize to be able to monitor the increment
00056       m_vSize = info.vsize;
00057     }
00058 
00059     log << MSG::INFO << msg << " " << caller << " " << evt <<
00060         " \tvirtual size = " << info.vsize << " MB"  <<
00061         " \tresident set size = " << info.rss << " MB" <<
00062         " deltaVsize = " << deltaVSize << "  MB" << endmsg;
00063   }
00064   // fill the stat for every call, not just when there is a change
00065   // only monitor the increment in VSize
00066   // Stat stv(statSvc(), caller + ":VMemUsage", info.vsize);
00067   // Stat str(statSvc(), caller + ":RMemUsage", info.rss);
00068   Stat sts(statSvc(), caller + ":VMem", deltaVSize);
00069 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Thu Jun 28 2012 23:27:16 for Gaudi Framework, version v23r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004