ATLAS Offline Software
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
CaloCellPos2Ntuple.int
int
Definition:
CaloCellPos2Ntuple.py:24
MemorySnooper::MemorySnooper
MemorySnooper(std::string where)
Definition:
MemorySnooper.h:19
ParticleGun_EoverP_Config.pid
pid
Definition:
ParticleGun_EoverP_Config.py:62
python.Utils.unixtools.where
def where(filename, prepath=[])
"which" for python files -------------------------------------------------—
Definition:
unixtools.py:53
MemorySnooper::imem
int imem
Definition:
MemorySnooper.h:46
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition:
Control/CxxUtils/Root/StringUtils.cxx:91
MemorySnooper::GetMemorySize
int GetMemorySize() const
Definition:
MemorySnooper.h:44
CaloCellTimeCorrFiller.filename
filename
Definition:
CaloCellTimeCorrFiller.py:24
makeTransCanvas.text
text
Definition:
makeTransCanvas.py:11
MemorySnooper
Definition:
MemorySnooper.h:17
Generated on Sun Dec 22 2024 21:14:21 for ATLAS Offline Software by
1.8.18