BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
MemorySnooper.h
Go to the documentation of this file.
1#ifndef MemorySnooper_H
2#define MemorySnooper_H
3
4#include <sys/types.h>
5#include <unistd.h>
6
7#include <string>
8#include <fstream>
9#include <sstream>
10
12public:
13 MemorySnooper(std::string where)
14 {
15 int pid=getpid();
16 std::ostringstream is;
17 is<<pid;
18 std::string spid=is.str();
19 std::string temp="cat /proc/"+spid+"/status | grep VmSize > mem.txt";
20 system(temp.c_str());
21 std::ifstream in("mem.txt");
22 std::string text,mem,text1;
23 in>>text>>mem>>text1;
24 system("rm -f mem.txt");
25 float memsize=atof(mem.c_str());
26 imem=int(memsize);
27 std::cout<<"*****************************************************"<<std::endl
28 <<"* *"<<std::endl
29 <<" Memory snooper called here "<<where<<std::endl
30 <<" process size at this point (VmMem): "<<imem<<" kBytes"<<std::endl
31 <<"* *"<<std::endl
32 <<"*****************************************************"<<std::endl;
33 }
34 int GetMemorySize() const {return imem;}
35private:
36 int imem;
37};
38
39#endif
MemorySnooper(std::string where)
Definition: MemorySnooper.h:13
int GetMemorySize() const
Definition: MemorySnooper.h:34