]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMemoryWatcher.h
Introduction of equipment id map. The map is taken from simple ascii formatted file...
[u/mrichter/AliRoot.git] / STEER / AliMemoryWatcher.h
index 2c31cdaf2f28970fdc505eefec82d18db22fe552..4a7492b04b99f6029b84b2a88be0265f0e4cf0cf 100644 (file)
@@ -2,40 +2,44 @@
 #define ALIMEMORYWATCHER_H
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice     */
+
 /* $Id$ */
+
 //_________________________________________________________________________
-/*Basic Memory Leak utility.
-    
-    You can use this tiny class to *see* if your program is leaking.
-    Usage:
-    AliMemoryWatcher memwatcher;
-    some program loop on events here {
-      if ( nevents % x == 0 ) 
-      {
-      // take a sample every x events
-        memwatcher.watch(nevents);
-      }
-    }
-    TFile f("out.root","RECREATE");
-    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 :
-    - VSIZE is the virtual size (in KBytes) of your program, that is sort of
-    the total memory used
-    - RSSIZE is the resident size (in KBytes), that is, the part of your 
-    program which is really in physical memory.
-    - TIME is an estimate of time per event (really it's the time elasped
-    between two calls to watch method)
-    WARNING: this is far from a bulletproof memory report (it's basically 
-    using UNIX command ps -h -p [PID] -o vsize,rssize to do its job).
-    It has only been tested on Linux so far.
-    
-    But by fitting the VSIZE by a pol1 under ROOT, you'll see right away
-    by how much your program is leaking.
-*/             
+//Basic Memory Leak utility.
+//  
+//  You can use this tiny class to *see* if your program is leaking.
+//  Usage:
+//  AliMemoryWatcher memwatcher;
+//  some program loop on events here {
+//    if ( nevents % x == 0 ) 
+//    {
+//    // take a sample every x events
+//      memwatcher.watch(nevents);
+//    }
+//  }
+//  TFile f("out.root","RECREATE");
+//  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 :
+//  - VSIZE is the virtual size (in KBytes) of your program, that is sort of
+//  the total memory used
+//  - RSSIZE is the resident size (in KBytes), that is, the part of your 
+//  program which is really in physical memory.
+//  - TIME is an estimate of time per event (really it's the time elasped
+//  between two calls to watch method)
+//  WARNING: this is far from a bulletproof memory report (it's basically 
+//  using UNIX command ps -h -p [PID] -o vsize,rssize to do its job).
+//  It has only been tested on Linux so far.
+//  
+//  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)
+
 // --- ROOT system ---
+
 #include "TObject.h" 
 class TH2;
 class TGraph;
@@ -46,6 +50,7 @@ public:
   AliMemoryWatcher(UInt_t maxsize=10000);
   AliMemoryWatcher(const AliMemoryWatcher& mw);
   ~AliMemoryWatcher() ;
+  void SetUseMallinfo(Bool_t use) { fUseMallinfo = use; }
   void Watch(Int_t x);
   
   UInt_t Size(void) const { return fSize; }
@@ -57,9 +62,10 @@ public:
   TGraph* GraphRSSIZE(void);
   TGraph* GraphTIME(void);
   TH2* Frame(void) const ;
-  void Write(void);
+  Int_t       WriteToFile();
   AliMemoryWatcher & operator = (const AliMemoryWatcher &) { return *this; } 
 private:
+  Bool_t fUseMallinfo; // use mallinfo function instead of ps command
   Int_t fPID;          // PID of the process to watch
   char fCmd[1024];     // the command sent to the system to retrieve things ("ps .....")
   UInt_t fMAXSIZE;     // maximum size of arrays where the informationis stored