| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

# 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   m_stat = serviceLocator()->service("ChronoStatSvc");
    00023 }
    00024
    00025 void MemStatAuditor::i_before(CustomEventTypeRef /*evt*/, const std::string& /*caller*/) {
    00026   // It's not interesting to monitor the memory usage before the methods.
    00027 }
    00028
    00029 void MemStatAuditor::i_printinfo(const std::string& msg, CustomEventTypeRef evt, const std::string& caller) {
    00030   // cannot be exactly 0
    00031   double deltaVSize = 0.00001;
    00032
    00033   procInfo info;
    00034   if (getProcInfo(info)) {
    00035     MsgStream log(msgSvc(), name());
    00036
    00037     if (info.vsize > 0) {
    00038       if (m_vSize > 0){
    00039         deltaVSize = info.vsize - m_vSize;
    00040       }
    00041       // store the current VSize to be able to monitor the increment
    00042       m_vSize = info.vsize;
    00043     }
    00044
    00045     log << MSG::INFO << msg << " " << caller << " " << evt <<
    00046         " \tvirtual size = " << info.vsize << " MB"  <<
    00047         " \tresident set size = " << info.rss << " MB" <<
    00048         " deltaVsize = " << deltaVSize << "  MB" << endmsg;
    00049   }
    00050   // fill the stat for every call, not just when there is a change
    00051   // only monitor the increment in VSize
    00052   // Stat stv(statSvc(), caller + ":VMemUsage", info.vsize);
    00053   // Stat str(statSvc(), caller + ":RMemUsage", info.rss);
    00054   Stat sts(statSvc(), caller + ":VMem", deltaVSize);
    00055 }

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines