]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMemoryWatcher.h
Fixed compilation
[u/mrichter/AliRoot.git] / STEER / AliMemoryWatcher.h
CommitLineData
ac8cd48d 1#ifndef ALIMEMORYWATCHER_H
2#define ALIMEMORYWATCHER_H
d60522e4 3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
0742d588 5
d60522e4 6/* $Id$ */
0742d588 7
d60522e4 8//_________________________________________________________________________
0742d588 9//Basic Memory Leak utility.
10//
11// You can use this tiny class to *see* if your program is leaking.
12// Usage:
13// AliMemoryWatcher memwatcher;
14// some program loop on events here {
15// if ( nevents % x == 0 )
16// {
17// // take a sample every x events
18// memwatcher.watch(nevents);
19// }
20// }
21// TFile f("out.root","RECREATE");
22// memwatcher.write();
23// f.Close();
24// In the output root file you'll get 3 graphs representing
25// the evolAliPHOSon, as a function of the number of events, of :
26// - VSIZE is the virtual size (in KBytes) of your program, that is sort of
27// the total memory used
28// - RSSIZE is the resident size (in KBytes), that is, the part of your
29// program which is really in physical memory.
30// - TIME is an estimate of time per event (really it's the time elasped
31// between two calls to watch method)
32// WARNING: this is far from a bulletproof memory report (it's basically
33// using UNIX command ps -h -p [PID] -o vsize,rssize to do its job).
34// It has only been tested on Linux so far.
35//
36// But by fitting the VSIZE by a pol1 under ROOT, you'll see right away
37// by how much your program is leaking.
38//
d60522e4 39//*-- Author: Laurent Aphecetche(SUBATECH)
0742d588 40
d60522e4 41// --- ROOT system ---
0742d588 42
d60522e4 43#include "TObject.h"
44class TH2;
45class TGraph;
46class TStopwatch;
ac8cd48d 47class AliMemoryWatcher : public TObject
d60522e4 48{
49public:
ac8cd48d 50 AliMemoryWatcher(UInt_t maxsize=10000);
d1898505 51 AliMemoryWatcher(const AliMemoryWatcher& mw);
ac8cd48d 52 ~AliMemoryWatcher() ;
b01af8c2 53 void Watch(Int_t x);
d60522e4 54
00399209 55 UInt_t Size(void) const { return fSize; }
b01af8c2 56 Int_t X(Int_t n) const { return fX[n]; }
57 Int_t VSIZE(Int_t n) const { return fVSIZE[n]; }
58 Int_t RSSIZE(Int_t n) const { return fRSSIZE[n]; }
59 Double_t TIME(Int_t n) const { return fTIME[n]; }
60 TGraph* GraphVSIZE(void);
61 TGraph* GraphRSSIZE(void);
62 TGraph* GraphTIME(void);
63 TH2* Frame(void) const ;
c4cb6153 64 Int_t WriteToFile();
ac8cd48d 65 AliMemoryWatcher & operator = (const AliMemoryWatcher &) { return *this; }
d60522e4 66private:
00399209 67 UInt_t fMAXSIZE; // maximum size of arrays where the informationis stored
68 UInt_t fSize; // the requested size of information to be retrieved
9f50efc4 69 Int_t* fX; //[fMAXSIZE] array that contains the step numbers
70 Int_t* fVSIZE; //[fMAXSIZE] array that contains the virtual memory at each step
71 Int_t* fRSSIZE; //[fMAXSIZE] array that contains the real memory at each step
72 Double_t* fTIME; //[fMAXSIZE] array that contains the CPU time at each step
00399209 73 TStopwatch* fTimer; // the chronometer
74 Bool_t fDisabled; // to switch on/off the monitoring
dfe7f75b 75
7f602369 76 ClassDef(AliMemoryWatcher,2) // General purpose memory watcher
dfe7f75b 77
d60522e4 78} ;
4ed9ed00 79#endif