X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliMemoryWatcher.cxx;h=63bb6e8cf6a53bda893dc2030b11f2794099769b;hb=f12dabf047497f243db3d7b57775f2f2b639d2ae;hp=d292b601b6e2ef83619d5ac445f0e31cc37b8595;hpb=54ee927c81b4221e8798b653e1a0bfd8c34a5371;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliMemoryWatcher.cxx b/STEER/AliMemoryWatcher.cxx index d292b601b6e..63bb6e8cf6a 100644 --- a/STEER/AliMemoryWatcher.cxx +++ b/STEER/AliMemoryWatcher.cxx @@ -13,6 +13,7 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ /* $Id$ */ + //_________________________________________________________________________ //Basic Memory Leak utility. // You can use this tiny class to *see* if your program is leaking. @@ -42,12 +43,11 @@ // But by fitting the VSIZE by a pol1 under ROOT, you'll see right away // by how much your program is leaking. //*-- Author: Laurent Aphecetche(SUBATECH) + // --- std system --- #include -#ifdef __APPLE__ +#ifdef NEVER #include -#else -#include #endif // --- AliRoot header files --- #include "AliLog.h" @@ -64,8 +64,6 @@ ClassImp(AliMemoryWatcher) //_____________________________________________________________________________ AliMemoryWatcher::AliMemoryWatcher(UInt_t maxsize) : TObject(), - fUseMallinfo(kTRUE), - fPID(gSystem->GetPid()), fMAXSIZE(maxsize), fSize(0), fX(new Int_t[fMAXSIZE]), @@ -78,14 +76,11 @@ AliMemoryWatcher::AliMemoryWatcher(UInt_t maxsize) : // //ctor // - sprintf(fCmd,"ps -h -p %d -o vsize,rssize",fPID); } //_____________________________________________________________________________ AliMemoryWatcher::AliMemoryWatcher(const AliMemoryWatcher& mw): TObject(mw), - fUseMallinfo(mw.fUseMallinfo), - fPID(mw.fPID), fMAXSIZE(mw.fMAXSIZE), fSize(0), fX(new Int_t[fMAXSIZE]), @@ -96,7 +91,6 @@ AliMemoryWatcher::AliMemoryWatcher(const AliMemoryWatcher& mw): fDisabled(kFALSE) { //copy ctor - strcpy(fCmd, mw.fCmd) ; } //_____________________________________________________________________________ @@ -112,45 +106,46 @@ AliMemoryWatcher::~AliMemoryWatcher() //_____________________________________________________________________________ void AliMemoryWatcher::Watch(Int_t x) { + static ProcInfo_t meminfo; +#ifdef NEVER + static Char_t cmd[1024]=""; +#endif // Sets the point where CPU parameters have to be monitored if ( !fDisabled && fSize < fMAXSIZE ) { if ( fSize==0 ) { - assert(fTimer==0); fTimer = new TStopwatch; fTimer->Start(true); fTimer->Stop(); +#ifdef NEVER + if(!cmd[0]) + sprintf(cmd,"ps -h -p %d -o vsz,rss | grep -v VSZ",gSystem->GetPid()); +#endif } - if ( fUseMallinfo ) { -#ifdef __linux - static struct mallinfo meminfo; - meminfo = mallinfo(); + gSystem->GetProcInfo(&meminfo); + fX[fSize] = x ; + fVSIZE[fSize] = meminfo.fMemVirtual / 1024; + fRSSIZE[fSize] = meminfo.fMemResident / 1024; + fTIME[fSize] = fTimer->CpuTime(); + fSize++; +#ifdef NEVER + Int_t vsize, rssize; + FILE* pipe = 0; + pipe = popen(cmd,"r"); + if ( pipe ) { + + fscanf(pipe,"%d %d",&vsize,&rssize); + fX[fSize] = x ; - fVSIZE[fSize] = (meminfo.hblkhd + meminfo.uordblks) / 1024; - fRSSIZE[fSize] = meminfo.uordblks / 1024; + fVSIZE[fSize] = vsize ; + fRSSIZE[fSize] = rssize ; fTIME[fSize] = fTimer->CpuTime(); fSize++; -#else - AliFatal("Please SetUseMallinfo to kFALSE on this system"); -#endif - } else { - static Int_t vsize, rssize; - static FILE* pipe = 0; - pipe = popen(fCmd,"r"); - if ( pipe ) { - - fscanf(pipe,"%d %d",&vsize,&rssize); - - fX[fSize] = x ; - fVSIZE[fSize] = vsize ; - fRSSIZE[fSize] = rssize ; - fTIME[fSize] = fTimer->CpuTime(); - fSize++; - } - assert(pclose(pipe)!=-1); } + Int_t iclose=pclose(pipe); + assert(iclose!=-1); +#endif fTimer->Start(true); - } - else { + } else { fDisabled=true; AliError("I'm full !" ) ; }