]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMemoryWatcher.cxx
Updates.
[u/mrichter/AliRoot.git] / STEER / AliMemoryWatcher.cxx
index 634c758f005547d5c34660b67036a5260e0ae7fc..8147b1e544d6be61d1b4286a4b4f996e80f214a2 100644 (file)
@@ -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.
 //       if ( nevents % x == 0 ) 
 //       {
 //       // take a sample every x events
-//         memwatcher.watch(nevents);
+//         memwatcher.Watch(nevents);
 //       }
 //     }
 //     TFile f("out.root","RECREATE");
-//     memwatcher.write();
+//     memwatcher.Write();
 //     f.Close();
 //     In the output root file you'll get 3 graphs representing
 //     the evolAliPHOSon, as a function of the number of events, of :
 //     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 ---
-class assert ; 
+#include <cassert> 
+#ifdef __APPLE__
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 // --- AliRoot header files ---
+#include "AliLog.h"
 #include "AliMemoryWatcher.h"
 // --- ROOT system ---
 #include "TSystem.h"
 #include "TGraph.h"
 #include "TH2.h"
 #include "TStopwatch.h"
+#include "TError.h"
 
 ClassImp(AliMemoryWatcher)
 
 //_____________________________________________________________________________
-AliMemoryWatcher::AliMemoryWatcher(UInt_t maxsize)
+AliMemoryWatcher::AliMemoryWatcher(UInt_t maxsize) :
+  TObject(),
+  fUseMallinfo(kTRUE),
+  fPID(gSystem->GetPid()),
+  fMAXSIZE(maxsize),
+  fSize(0),
+  fX(new Int_t[fMAXSIZE]),
+  fVSIZE(new Int_t[fMAXSIZE]),
+  fRSSIZE(new Int_t[fMAXSIZE]),
+  fTIME(new Double_t[fMAXSIZE]),
+  fTimer(0),
+  fDisabled(kFALSE)
 {
+  //
   //ctor
-  fMAXSIZE=maxsize;
-  fUseMallinfo = true;
-  fPID = gSystem->GetPid();
-  sprintf(fCmd,"ps -h -p %d -o vsize,rssize",fPID);
-  fX = new Int_t[fMAXSIZE];
-  fVSIZE = new Int_t[fMAXSIZE];
-  fRSSIZE = new Int_t[fMAXSIZE];
-  fTIME = new Double_t[fMAXSIZE];
-  fSize=0;
-  fDisabled=false;
-  fTimer=0;
+  //
+  sprintf(fCmd,"ps -h -p %d -o vsz,rss | grep -v VSZ",fPID);
 }
+
 //_____________________________________________________________________________
 AliMemoryWatcher::AliMemoryWatcher(const AliMemoryWatcher& mw):
-  TObject(mw)
+  TObject(mw),
+  fUseMallinfo(mw.fUseMallinfo),
+  fPID(mw.fPID),
+  fMAXSIZE(mw.fMAXSIZE),
+  fSize(0),
+  fX(new Int_t[fMAXSIZE]),
+  fVSIZE(new Int_t[fMAXSIZE]),
+  fRSSIZE(new Int_t[fMAXSIZE]),
+  fTIME(new Double_t[fMAXSIZE]),
+  fTimer(0),
+  fDisabled(kFALSE)
 {
   //copy ctor
-  fMAXSIZE = mw.fMAXSIZE ;
-  fUseMallinfo = mw.fUseMallinfo;
-  fPID = mw.fPID ; 
   strcpy(fCmd, mw.fCmd) ; 
-  fX = new Int_t[fMAXSIZE];
-  fVSIZE = new Int_t[fMAXSIZE];
-  fRSSIZE = new Int_t[fMAXSIZE];
-  fTIME = new Double_t[fMAXSIZE];
-  fSize=0;
-  fDisabled=false;
-  fTimer=0;   
 }
+
 //_____________________________________________________________________________
 AliMemoryWatcher::~AliMemoryWatcher()
 {
@@ -119,7 +132,7 @@ void AliMemoryWatcher::Watch(Int_t x)
       fTIME[fSize] = fTimer->CpuTime();
       fSize++;
 #else
-      ::Fatal("Watch","Please SetUseMallinfo to kFALSE on this system");
+      AliFatal("Please SetUseMallinfo to kFALSE on this system");
 #endif
     } else {
       static Int_t vsize, rssize;
@@ -141,7 +154,7 @@ void AliMemoryWatcher::Watch(Int_t x)
   }
   else {
     fDisabled=true;
-    Error("watch", "I'm full !" ) ;
+    AliError("I'm full !" ) ;
   }
 }
 //_____________________________________________________________________________
@@ -215,7 +228,7 @@ AliMemoryWatcher::Frame(void) const
 }
 //_____________________________________________________________________________
 Int_t
-AliMemoryWatcher::Write(const char *, Int_t, Int_t)
+AliMemoryWatcher::WriteToFile()
 {
   // Stores the graphs in a file 
   if ( GraphVSIZE() ) GraphVSIZE()->Write("VSIZE",TObject::kOverwrite);