ATLAS Offline Software
Loading...
Searching...
No Matches
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
11namespace 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}
MemStruct getMemUsage()
std::ostream & operator<<(std::ostream &os, const MemStruct &s)
std::istream & operator>>(std::istream &is, MemStruct &s)