ATLAS Offline Software
Loading...
Searching...
No Matches
MemoryMonitorModule.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9//
10// includes
11//
12
14
16#include <TSystem.h>
17
18//
19// method implementations
20//
21
22namespace EL
23{
24 namespace Detail
25 {
26 StatusCode MemoryMonitorModule ::
27 firstInitialize (ModuleData& /*data*/)
28 {
29 ANA_CHECK (printMemoryUsage ("firstInitialize"));
30 return StatusCode::SUCCESS;
31 }
32
33
34
35 StatusCode MemoryMonitorModule ::
36 onInitialize (ModuleData& /*data*/)
37 {
38 ANA_CHECK (printMemoryUsage ("onInitialize"));
39 return StatusCode::SUCCESS;
40 }
41
42
43
44 StatusCode MemoryMonitorModule ::
45 onExecute (ModuleData& /*data*/)
46 {
48 {
51 m_executeStep *= 10, m_executeTarget *= 10;
52
53 ANA_CHECK (printMemoryUsage ("onExecute(" + std::to_string (m_numExecute) + ")"));
54 }
55 return StatusCode::SUCCESS;
56 }
57
58
59
60 StatusCode MemoryMonitorModule ::
61 postFirstEvent (ModuleData& /*data*/)
62 {
63 ANA_CHECK (printMemoryUsage ("postFirstEvent"));
64 return StatusCode::SUCCESS;
65 }
66
67
68
69 StatusCode MemoryMonitorModule ::
70 onFinalize (ModuleData& /*data*/)
71 {
72 ANA_CHECK (printMemoryUsage ("onFinalize"));
73 return StatusCode::SUCCESS;
74 }
75
76
77
78 StatusCode MemoryMonitorModule ::
79 onWorkerEnd (ModuleData& /*data*/)
80 {
81 ANA_CHECK (printMemoryUsage ("onWorkerEnd"));
82 return StatusCode::SUCCESS;
83 }
84
85
86
87 StatusCode MemoryMonitorModule ::
88 printMemoryUsage (const std::string& location)
89 {
90 ::ProcInfo_t pinfo;
91 if (gSystem->GetProcInfo (&pinfo) != 0) {
92 ANA_MSG_ERROR ("Could not get memory usage information");
93 return StatusCode::FAILURE;
94 }
95 ANA_MSG_INFO ("Memory usage at " << location << ": " << pinfo.fMemResident << " kB resident, " << pinfo.fMemVirtual << " kB virtual");
96 lastRSS = pinfo.fMemResident;
97 return StatusCode::SUCCESS;
98 }
99 }
100}
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
std::optional< std::uint64_t > lastRSS
the last RSS value read
StatusCode printMemoryUsage(const std::string &location)
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.
the data the EventLoop core classes are sharing with the Module implementation
Definition ModuleData.h:64