ATLAS Offline Software
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 
10 #include <fstream>
11 #include <sstream>
12 
14  : m_vsize{ -1 }
15  , m_rss{ -1 }
16 {}
17 
18 void
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 }
get_hdefs.buff
buff
Definition: get_hdefs.py:64
Trk::MemoryLogger::refresh
void refresh(int pid) const
update the memory logger
Definition: MemoryLogger.cxx:19
Trk::MemoryLogger::vmRss
float vmRss() const
Definition: MemoryLogger.h:55
Trk::MemoryLogger::MemoryLogger
MemoryLogger()
Default constructor.
Definition: MemoryLogger.cxx:13
Trk::MemoryLogger
Definition: MemoryLogger.h:31
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
Trk::MemoryLogger::vmSize
float vmSize() const
vsize/rss returnal
Definition: MemoryLogger.h:49
MemoryLogger.h
Trk::operator<<
MsgStream & operator<<(MsgStream &sl, const AlignModule &alignModule)
overload of << operator for MsgStream for debug output
Definition: AlignModule.cxx:204
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
merge.status
status
Definition: merge.py:17