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 {
52 m_executeStep *= 10;
53 m_executeTarget *= 10;
54 }
55
56 ANA_CHECK (printMemoryUsage ("onExecute(" + std::to_string (m_numExecute) + ")"));
57 }
58 return StatusCode::SUCCESS;
59 }
60
61
62
63 StatusCode MemoryMonitorModule ::
64 postFirstEvent (ModuleData& /*data*/)
65 {
66 ANA_CHECK (printMemoryUsage ("postFirstEvent"));
67 return StatusCode::SUCCESS;
68 }
69
70
71
72 StatusCode MemoryMonitorModule ::
73 onFinalize (ModuleData& /*data*/)
74 {
75 ANA_CHECK (printMemoryUsage ("onFinalize"));
76 return StatusCode::SUCCESS;
77 }
78
79
80
81 StatusCode MemoryMonitorModule ::
82 onWorkerEnd (ModuleData& /*data*/)
83 {
84 ANA_CHECK (printMemoryUsage ("onWorkerEnd"));
85 return StatusCode::SUCCESS;
86 }
87
88
89
90 StatusCode MemoryMonitorModule ::
91 printMemoryUsage (const std::string& location)
92 {
93 ::ProcInfo_t pinfo;
94 if (gSystem->GetProcInfo (&pinfo) != 0) {
95 ANA_MSG_ERROR ("Could not get memory usage information");
96 return StatusCode::FAILURE;
97 }
98 ANA_MSG_INFO ("Memory usage at " << location << ": " << pinfo.fMemResident << " kB resident, " << pinfo.fMemVirtual << " kB virtual");
99 lastRSS = pinfo.fMemResident;
100 return StatusCode::SUCCESS;
101 }
102 }
103}
#define ANA_MSG_ERROR(xmsg,...)
Macro printing error messages.
#define ANA_MSG_INFO(xmsg,...)
Macro printing info 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