/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Simulation/SimHelpers/SimHelpers-00-00-01/SimHelpers/MemorySnooper.h

Go to the documentation of this file.
00001 #ifndef MemorySnooper_H
00002 #define MemorySnooper_H
00003 
00004 #include <sys/types.h>
00005 #include <unistd.h>
00006 
00007 #include <string>
00008 #include <fstream>
00009 #include <sstream>
00010 
00011 class MemorySnooper {
00012 public:
00013         MemorySnooper(std::string where)
00014         {
00015                 int pid=getpid();
00016                 std::ostringstream is;
00017                 is<<pid;
00018                 std::string spid=is.str();
00019                 std::string temp="cat /proc/"+spid+"/status | grep VmSize > mem.txt";
00020                 system(temp.c_str());
00021                 std::ifstream in("mem.txt");
00022                 std::string text,mem,text1;
00023                 in>>text>>mem>>text1;
00024                 system("rm -f mem.txt");
00025                 float memsize=atof(mem.c_str());
00026                 imem=int(memsize);
00027                 std::cout<<"*****************************************************"<<std::endl
00028                          <<"*                                                   *"<<std::endl
00029                          <<"  Memory snooper called here "<<where<<std::endl
00030                          <<"  process size at this point (VmMem): "<<imem<<" kBytes"<<std::endl
00031                          <<"*                                                   *"<<std::endl
00032                          <<"*****************************************************"<<std::endl;
00033         }
00034         int GetMemorySize() const {return imem;}
00035 private:
00036         int imem;
00037 };
00038 
00039 #endif

Generated on Tue Nov 29 23:14:35 2016 for BOSS_7.0.2 by  doxygen 1.4.7