BOSS 8.0.0
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 <fstream>
8#include <sstream>
9#include <string>
10
12public:
13 MemorySnooper( std::string where ) {
14 int pid = getpid();
15 std::ostringstream is;
16 is << pid;
17 std::string spid = is.str();
18 std::string temp = "cat /proc/" + spid + "/status | grep VmSize > mem.txt";
19 system( temp.c_str() );
20 std::ifstream in( "mem.txt" );
21 std::string text, mem, text1;
22 in >> text >> mem >> text1;
23 system( "rm -f mem.txt" );
24 float memsize = atof( mem.c_str() );
25 imem = int( memsize );
26 std::cout << "*****************************************************" << std::endl
27 << "* *" << std::endl
28 << " Memory snooper called here " << where << std::endl
29 << " process size at this point (VmMem): " << imem << " kBytes" << std::endl
30 << "* *" << std::endl
31 << "*****************************************************" << std::endl;
32 }
33 int GetMemorySize() const { return imem; }
34
35private:
36 int imem;
37};
38
39#endif
MemorySnooper(std::string where)
int GetMemorySize() const