ATLAS Offline Software
getMemUsage.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "getMemUsage.h"
6 #include <unistd.h>
7 #include <iostream>
8 #include <fstream>
9 #include <string>
10 
11 namespace PSUtils
12 {
14  {
15  int pid = getpid();
16  const std::string ost="/proc/"+std::to_string(pid)+"/statm";
17  std::ifstream ifile( ost.c_str(), std::ifstream::in );
18 
19  MemStruct ms;
20  ifile>>ms;
21  ifile.close();
22  return ms;
23  }
24 
25  std::ostream& operator<<(std::ostream& os, const MemStruct& s)
26  {
27  // sizes in pages
28 
29  os <<
30  " totalSize " <<s.totalSize<<
31  " physicalMemSize "<<s.physicalMemSize<<
32  " sharedMemSize " <<s.sharedMemSize<<
33  " stackSize " <<s.stackSize;
34  return os;
35  }
36  std::istream& operator>>(std::istream& is, MemStruct& s)
37  {
38  is
39  >>s.totalSize
40  >>s.physicalMemSize
41  >>s.sharedMemSize
42  >>s.textSize
43  >>s.sharedLibSize
44  >>s.stackSize
45  >>s.nDirtyPages;
46  return is;
47  }
48 }
TestSUSYToolsAlg.ifile
ifile
Definition: TestSUSYToolsAlg.py:92
PSUtils
Definition: getMemUsage.cxx:12
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
getMemUsage.h
PSUtils::MemStruct
Definition: getMemUsage.h:14
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
PSUtils::getMemUsage
MemStruct getMemUsage()
Definition: getMemUsage.cxx:13
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
PSUtils::operator>>
std::istream & operator>>(std::istream &is, MemStruct &s)
Definition: getMemUsage.cxx:36
PSUtils::operator<<
std::ostream & operator<<(std::ostream &os, const MemStruct &s)
Definition: getMemUsage.cxx:25