ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Sim
SimHelpers
SimHelpers
MemorySnooper.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef MemorySnooper_H
6
#define MemorySnooper_H
7
8
#include <sys/types.h>
9
#include <unistd.h>
10
11
#include <cstdlib>
12
#include <string>
13
#include <fstream>
14
#include <sstream>
15
16
class
MemorySnooper
17
{
18
public
:
19
MemorySnooper
(std::string where)
20
{
21
int
pid=getpid();
22
std::ostringstream is;
23
is<<pid;
24
std::string spid=is.str();
25
std::string filename=
"mem"
+spid+
".txt"
;
26
std::string temp=
"cat /proc/"
+spid+
"/status | grep VmSize >"
+filename;
27
system(temp.c_str());
28
std::ifstream in(filename.c_str());
29
std::string text,mem,text1;
30
in>>text>>mem>>text1;
31
temp=
"rm -f "
+filename;
32
system(temp.c_str());
33
float
memsize=atof(mem.c_str());
34
imem
=int(memsize);
35
std::cout <<
"* Memory snooper called at "
<< where
36
<<
" with VMEM: "
<<
imem
<<
"kB"
<< std::endl;
37
//std::cout<<"*****************************************************"<<std::endl
38
// <<"* *"<<std::endl
39
// <<" Memory snooper called here "<<where<<std::endl
40
// <<" process size at this point (VmMem): "<<imem<<" kBytes"<<std::endl
41
// <<"* *"<<std::endl
42
// <<"*****************************************************"<<std::endl;
43
}
44
int
GetMemorySize
()
const
{
return
imem
;}
45
private
:
46
int
imem
;
47
};
48
49
#endif
MemorySnooper::imem
int imem
Definition
MemorySnooper.h:46
MemorySnooper::MemorySnooper
MemorySnooper(std::string where)
Definition
MemorySnooper.h:19
MemorySnooper::GetMemorySize
int GetMemorySize() const
Definition
MemorySnooper.h:44
Generated on
for ATLAS Offline Software by
1.17.0