ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkDetDescr
TrkDetDescrUtils
src
MemoryLogger.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// MemoryLogger.cxx, (c) ATLAS Detector software
8
9
#include "
TrkDetDescrUtils/MemoryLogger.h
"
10
#include <fstream>
11
#include <sstream>
12
13
Trk::MemoryLogger::MemoryLogger
()
14
:
m_vsize
{ -1 }
15
,
m_rss
{ -1 }
16
{}
17
18
void
19
Trk::MemoryLogger::refresh
(
int
pid)
const
20
{
21
22
#ifndef __APPLE__
23
// memory monitoring
24
std::ostringstream filename;
25
filename <<
"/proc/"
<< pid <<
"/status"
;
26
27
std::ifstream status(filename.str().c_str());
28
std::string buff;
29
float
vsize;
30
float
rss;
31
// loop over the files in the input
32
while
(!status.eof()) {
33
status >> buff;
34
if
(buff ==
"VmSize:"
)
35
status >> vsize;
36
if
(buff ==
"VmRSS:"
)
37
status >> rss;
38
}
39
// close the file again
40
status.close();
41
m_vsize
.store(vsize);
42
m_rss
.store(vsize);
43
#else
44
#warning MemoryLogger does not yet work on the mac.
45
#endif
46
}
47
49
MsgStream&
50
Trk::operator<<
(MsgStream& sl,
const
Trk::MemoryLogger
& mlg)
51
{
52
sl <<
"[ memory usage ] in kB ( VmSize | VmRSS ) : "
<< mlg.
vmSize
() <<
'\t'
<< mlg.
vmRss
();
53
return
sl;
54
}
55
56
std::ostream&
57
Trk::operator<<
(std::ostream& sl,
const
Trk::MemoryLogger
& mlg)
58
{
59
sl <<
"[ memory usage ] in kB ( VmSize | VmRSS ) : "
<< mlg.
vmSize
() <<
'\t'
<< mlg.
vmRss
();
60
return
sl;
61
}
MemoryLogger.h
Trk::MemoryLogger
A small helper class looking at /proc/<PID>status.
Definition
MemoryLogger.h:31
Trk::MemoryLogger::m_rss
std::atomic< float > m_rss
real memory size
Definition
MemoryLogger.h:45
Trk::MemoryLogger::vmRss
float vmRss() const
Definition
MemoryLogger.h:55
Trk::MemoryLogger::vmSize
float vmSize() const
vsize/rss returnal
Definition
MemoryLogger.h:49
Trk::MemoryLogger::MemoryLogger
MemoryLogger()
Default constructor.
Definition
MemoryLogger.cxx:13
Trk::MemoryLogger::m_vsize
std::atomic< float > m_vsize
virtual memory size
Definition
MemoryLogger.h:44
Trk::MemoryLogger::refresh
void refresh(int pid) const
update the memory logger
Definition
MemoryLogger.cxx:19
Trk::operator<<
MsgStream & operator<<(MsgStream &sl, const AlignModule &alignModule)
overload of << operator for MsgStream for debug output
Definition
AlignModule.cxx:204
Generated on
for ATLAS Offline Software by
1.17.0