The Gaudi Framework
master (181af51f)
Loading...
Searching...
No Matches
MemoryAuditor.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2025 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
#include "
ProcStats.h
"
15
#include <
Gaudi/Auditor.h
>
16
#include <
GaudiKernel/MsgStream.h
>
17
22
class
MemoryAuditor
:
public
Gaudi::Auditor
{
23
public
:
24
using
Auditor::Auditor;
25
26
protected
:
28
void
before
( std::string
const
& evt, std::string
const
&,
EventContext
const
& )
override
;
29
31
void
after
( std::string
const
& evt, std::string
const
& caller,
EventContext
const
&,
const
StatusCode
& sc )
override
;
32
34
virtual
void
i_printinfo
( std::string_view
msg
, std::string
const
& evt, std::string_view caller );
35
};
36
37
DECLARE_COMPONENT
(
MemoryAuditor
)
38
39
void
MemoryAuditor
::
before
(
std
::
string
const& evt,
std
::
string
const& caller,
EventContext
const& ) {
40
i_printinfo
(
"Memory usage before"
, evt, caller );
41
}
42
43
void
MemoryAuditor::after
( std::string
const
& evt, std::string
const
& caller,
EventContext
const
&,
const
StatusCode
& ) {
44
i_printinfo
(
"Memory usage has changed after"
, evt, caller );
45
}
46
47
void
MemoryAuditor::i_printinfo
( std::string_view
msg
, std::string
const
& evt, std::string_view caller ) {
50
if
(
procInfo
pInfo;
ProcStats::instance
()->
fetch
( pInfo ) ) {
51
if
( pInfo.vsize > 0 ) {
52
info
() <<
msg
<<
" "
<< caller <<
" "
<< evt <<
" virtual size = "
<< pInfo.vsize <<
" MB"
53
<<
" resident set size = "
<< pInfo.rss <<
" MB"
<<
endmsg
;
54
}
55
}
56
}
Auditor.h
MsgStream.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
ProcStats.h
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:122
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:113
EventContext
This class represents an entry point to all the event specific data.
Definition
EventContext.h:34
Gaudi::Auditor
Base class from which all concrete auditor classes should be derived.
Definition
Auditor.h:33
MemoryAuditor
Monitors the memory use of each algorithm.
Definition
MemoryAuditor.cpp:22
MemoryAuditor::i_printinfo
virtual void i_printinfo(std::string_view msg, std::string const &evt, std::string_view caller)
Report the memory usage.
Definition
MemoryAuditor.cpp:47
MemoryAuditor::before
void before(std::string const &evt, std::string const &, EventContext const &) override
Default (catch-all) "before" Auditor hook.
Definition
MemoryAuditor.cpp:39
MemoryAuditor::after
void after(std::string const &evt, std::string const &caller, EventContext const &, const StatusCode &sc) override
Default (catch-all) "after" Auditor hook.
Definition
MemoryAuditor.cpp:43
ProcStats::fetch
bool fetch(procInfo &fill_me)
Definition
ProcStats.cpp:259
ProcStats::instance
static ProcStats * instance()
Definition
ProcStats.cpp:239
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
std
STL namespace.
procInfo
Definition
ProcStats.h:29
GaudiAud
src
MemoryAuditor.cpp
Generated on Wed Oct 8 2025 09:53:36 for The Gaudi Framework by
1.13.1