]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSMemoryWatcher.h
Number of maxima in parent cluster added
[u/mrichter/AliRoot.git] / PHOS / AliPHOSMemoryWatcher.h
CommitLineData
d60522e4 1#ifndef AliPHOSMEMORYWATCHER_H
2#define AliPHOSMEMORYWATCHER_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5/* $Id$ */
d60522e4 6//_________________________________________________________________________
7/*Basic Memory Leak utility.
8
9 You can use this tiny class to *see* if your program is leaking.
d60522e4 10 Usage:
d60522e4 11 AliPHOSMemoryWatcher memwatcher;
d60522e4 12 some program loop on events here {
13 if ( nevents % x == 0 )
14 {
15 // take a sample every x events
16 memwatcher.watch(nevents);
17 }
18 }
d60522e4 19 TFile f("out.root","RECREATE");
20 memwatcher.write();
21 f.Close();
d60522e4 22 In the output root file you'll get 3 graphs representing
23 the evolAliPHOSon, as a function of the number of events, of :
24 - VSIZE is the virtual size (in KBytes) of your program, that is sort of
25 the total memory used
26 - RSSIZE is the resident size (in KBytes), that is, the part of your
27 program which is really in physical memory.
28 - TIME is an estimate of time per event (really it's the time elasped
29 between two calls to watch method)
d60522e4 30 WARNING: this is far from a bulletproof memory report (it's basically
31 using UNIX command ps -h -p [PID] -o vsize,rssize to do its job).
32 It has only been tested on Linux so far.
33
34 But by fitting the VSIZE by a pol1 under ROOT, you'll see right away
35 by how much your program is leaking.
36*/
37//*-- Author: Laurent Aphecetche(SUBATECH)
d60522e4 38// --- ROOT system ---
39#include "TObject.h"
40class TH2;
41class TGraph;
42class TStopwatch;
d60522e4 43class AliPHOSMemoryWatcher : public TObject
44{
45public:
d60522e4 46 AliPHOSMemoryWatcher(unsigned int maxsize=10000);
47 ~AliPHOSMemoryWatcher();
d60522e4 48 void watch(int x);
49
50 unsigned int size(void) const { return fSize; }
d60522e4 51 int X(int n) const { return fX[n]; }
52 int VSIZE(int n) const { return fVSIZE[n]; }
53 int RSSIZE(int n) const { return fRSSIZE[n]; }
54 double TIME(int n) const { return fTIME[n]; }
d60522e4 55 TGraph* graphVSIZE(void);
56 TGraph* graphRSSIZE(void);
57 TGraph* graphTIME(void);
d60522e4 58 TH2* frame(void);
d60522e4 59 void write(void);
d60522e4 60private:
61 int fPID;
62 char fCmd[1024];
63 unsigned int fMAXSIZE;
64 unsigned int fSize;
65 int* fX;
66 int* fVSIZE;
67 int* fRSSIZE;
68 double* fTIME;
69 TStopwatch* fTimer;
70 bool fDisabled;
dfe7f75b 71
72 ClassDef(AliPHOSMemoryWatcher,1) // General purpose memory watcher
73
d60522e4 74} ;
4ed9ed00 75#endif