Commit 240f83a9 authored by Stefan Hoeche's avatar Stefan Hoeche
Browse files

added memleak check in psi and event handler

parent 0e66aca6
......@@ -275,6 +275,8 @@ void Run_Parameter::Init(std::string path,std::string file,int argc,char* argv[]
for (int i(1);i<4;++i) seedstr+="_"+ToString(gen.m_seeds[i]);
gen.SetVariable("RNG_SEED",ToString(gen.m_seeds[0])+seedstr);
gen.SetVariable("MEMLEAK_WARNING_THRESHOLD",
ToString(dr.GetValue<int>("MEMLEAK_WARNING_THRESHOLD",1<<20)));
gen.m_timeout = dr.GetValue<double>("TIMEOUT",std::numeric_limits<double>::max());
if (gen.m_timeout<0.) gen.m_timeout=0.;
rpa->gen.m_timer.Start();
......
......@@ -9,7 +9,7 @@
#include "ATOOLS/Org/My_MPI.H"
#include "PHASIC++/Main/Process_Integrator.H"
#include "ATOOLS/Math/Random.H"
#include "ATOOLS/Org/RUsage.H"
#include <unistd.h>
using namespace PHASIC;
......@@ -38,6 +38,7 @@ Phase_Space_Integrator::Phase_Space_Integrator()
if (!read.ReadFromFile(ndecopt,"PSI_NDECOPT")) ndecopt=10;
else msg_Info()<<METHOD<<"(): Set n_{opt,dec} = "<<ndecopt<<".\n";
addtime=0.0;
lastrss=GetCurrentRSS();
}
Phase_Space_Integrator::~Phase_Space_Integrator()
......@@ -306,6 +307,16 @@ bool Phase_Space_Integrator::AddPoint(const double value)
<<FormatTime(size_t(timeest)-size_t((time-starttime)))
<<" left ) ["<<rpa->gen.Timer().StrFTime("%H:%M:%S")<<"] "<<endl;
#endif
size_t currentrss=GetCurrentRSS();
if (currentrss-lastrss>ToType<int>
(rpa->gen.Variable("MEMLEAK_WARNING_THRESHOLD"))) {
msg_Error()<<METHOD<<"() {\n"<<om::bold<<" Memory usage increased by "
<<(currentrss-lastrss)/(1<<20)<<" MB,"
<<" now "<<currentrss/(1<<20)<<" MB.\n"
<<om::red<<" This might indicate a memory leak!\n"
<<" Please monitor this process closely.\n"<<om::reset<<"}"<<std::endl;
}
lastrss=currentrss;
std::vector<double> stats(6);
stats[0]=psh->Process()->TotalResult()*rpa->Picobarn();
stats[1]=psh->Process()->TotalVar()*rpa->Picobarn();
......
#ifndef PHASIC_Main_Phase_Space_Integrator_H
#define PHASIC_Main_Phase_Space_Integrator_H
#include <stddef.h>
namespace PHASIC {class Phase_Space_Handler;}
namespace PHASIC {
......@@ -16,6 +18,7 @@ namespace PHASIC {
double value, maxerror, maxabserror, rstarttime, rlotime;
long unsigned int n, ncontrib, endopt, nlo, fin_opt, nstep, ncstep;
long int mn, mnstep, mncstep;
size_t lastrss;
Phase_Space_Handler *psh;
......
......@@ -14,6 +14,7 @@
#include "ATOOLS/Math/Random.H"
#include "ATOOLS/Org/Data_Reader.H"
#include "ATOOLS/Org/RUsage.H"
using namespace SHERPA;
......@@ -29,6 +30,7 @@ Event_Handler::Event_Handler():
p_phases = new Phase_List;
Data_Reader reader(" ",";","!","=");
m_checkweight = reader.GetValue<int>("CHECK_WEIGHT", 0);
m_lastrss=GetCurrentRSS();
}
Event_Handler::~Event_Handler()
......@@ -477,6 +479,16 @@ void Event_Handler::MPISync()
delete [] values;
}
#endif
size_t currentrss=GetCurrentRSS();
if (currentrss-m_lastrss>ToType<int>
(rpa->gen.Variable("MEMLEAK_WARNING_THRESHOLD"))) {
msg_Error()<<METHOD<<"() {\n"<<om::bold<<" Memory usage increased by "
<<(currentrss-m_lastrss)/(1<<20)<<" MB,"
<<" now "<<currentrss/(1<<20)<<" MB.\n"
<<om::red<<" This might indicate a memory leak!\n"
<<" Please monitor this process closely.\n"<<om::reset<<"}"<<std::endl;
}
m_lastrss=currentrss;
}
double Event_Handler::TotalXS()
......
......@@ -19,6 +19,7 @@ namespace SHERPA {
double m_n, m_addn, m_sum, m_sumsqr, m_maxweight;
double m_mn, m_msum, m_msumsqr;
bool m_checkweight;
size_t m_lastrss;
Phase_List * p_phases;
ATOOLS::Blob_List m_blobs, m_sblobs;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment