78 TH1I *hleaks, *hentry;
85 void memstatExample(
double update=0.01,
const char* fname=
"*") {
95 if (!fname || strlen(fname) <5 || strstr(fname,
"*")) {
99 fname = strstr(s.
Data()+ns-25,
"memstat");
101 printf(
"Analyzing file: %s\n",fname);
104 printf(
"Cannot open file %s\n",fname);
109 printf(
"cannot find the TMemStat TTree named T in file %s\n",fname);
113 printf(
"Illegal update value %g, changed to 0.01\n",
update);
116 if (
update < 0.001) printf(
"Warning update parameter is very small, processing may be slow\n");
121 Long64_t nsel = T->
Draw(
"pos:nbytes:time:btid",
"",
"goff");
134 imean = imean - imean%bw;
135 irms = irms -irms%bw;
139 if (ivmax > 2000000000 && ivmin <2000000000) {
143 printf(
"memory locations above 2GBytes will be ignored\n");
144 nsel = T->
Draw(
"pos:nbytes:time:btid",
"pos <2e9",
"goff");
152 imean = imean - imean%bw;
153 irms = irms -irms%bw;
154 nbins =
Int_t(4*irms/bw);
155 ivmin = imean -bw*nbins/2;
156 ivmax = ivmin+bw*nbins;
158 update *= 0.0001*V3[nsel-1];
162 memset(nbold,0,nvm*8);
164 h =
new TH1D(
"h",
Form(
"%s;pos;per cent of pages used",fname),nbins,ivmin,ivmax);
170 halloc =
new TH1D(
"halloc",
Form(
"%s;pos;number of mallocs",fname),nbins,ivmin,ivmax);
171 hfree =
new TH1D(
"hfree",
Form(
"%s;pos;number of frees",fname),nbins,ivmin,ivmax);
199 for (i=0;i<nsel;i++) {
202 nbytes = (
Int_t)V2[i];
205 if (bin<1 || bin>nbins)
continue;
209 if (dbin > nbytes) dbin = nbytes;
213 nb =
Int_t((nbytes-dbin)/dv);
214 if (bin+nb >nbins) nb = nbins-bin;
217 rest = nbytes-nb*dv-dbin;
220 if (nbold[ipos] > 0) printf(
"reallocating %d bytes (was %lld) at %lld, entry=%d\n",nbytes,nbold[ipos],ipos,i);
221 if (nbold[ipos] == 0) {
226 nbold[ipos] = nbytes;
229 nbytes = nbold[ipos];
230 if (bin+nb >nbins) nb = nbins-bin;
231 nbold[ipos] = 0; nleaks--;
232 if (nbytes <= 0)
continue;
234 if (dbin > nbytes) dbin = nbytes;
237 nb =
Int_t((nbytes-dbin)/dv);
238 if (bin+nb >nbins) nb = nbins-bin;
241 rest = nbytes-nb*dv-dbin;
245 if (time -updateLast >
update) {
254 for (
Int_t k=1;k<nbins;k++) {
261 Double_t occupancy = mbytes/(nonEmpty*0.01*dv);
262 pvt->
AddText(
Form(
"memory used = %g Mbytes",mbytes*1
e-6));
263 pvt->
AddText(
Form(
"page occupancy = %f per cent",occupancy));
264 pvt->
AddText(
"(for non empty pages only)");
272 Int_t nlmax = nleaks;
279 for (
Int_t ii=0;ii<nvm;ii++) {
281 ileaks[nleaks] = (
Int_t)nbold[ii];
282 entry[nleaks] = ientry[ii];
284 if (nleaks > nlmax)
break;
289 hentry =
new TH1I(
"hentry",
"leak entry index",nleaks,0,nleaks);
290 hleaks =
new TH1I(
"hleaks",
"leaks;leak number;nbytes in leak",nleaks,0,nleaks);
291 for (
Int_t k=0;k<nleaks;k++) {
292 Int_t kk = lindex[k];
317 c2->
Connect(
"ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
318 0, 0,
"EventInfo(Int_t, Int_t, Int_t, TObject*)");
340 if (!btidlist) btidlist = (
TObjArray*)f->
Get(
"FAddrsList");
341 if (!btidlist)
return;
344 for (
Int_t i=0;i<nbt;i++) {
348 char *title = (
char*)nm->
GetTitle();
349 Int_t nch = strlen(title);
350 if (nch < 20)
continue;
351 if (nch > 100) title[100] =0;
352 const char *
bar = strstr(title,
"| ");
354 if (strstr(bar,
"operator new"))
continue;
355 if (strstr(bar,
"libMemStat"))
continue;
356 if (strstr(bar,
"G__Exception"))
continue;
361 TString form1 =
TString::Format(
" Leak number=%d, leaking %d bytes at entry=%d time=%gseconds\n\n",bin,nbytes,entry,time);
virtual Double_t * GetV3()
virtual void SetGridx(Int_t value=1)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
THist< 1, int, THistStatContent > TH1I
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
virtual void SetMaximum(Double_t maximum=-1111)
virtual Double_t * GetV4()
R__EXTERN TStyle * gStyle
virtual TString GetFromPipe(const char *command)
Execute command and return output in TString.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual void SetMinimum(Double_t minimum=-1111)
static constexpr double bar
TObject * At(Int_t idx) const
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Double_t RMS(Long64_t n, const T *a, const Double_t *w=0)
Return the Standard Deviation of an array a with length n.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
The TNamed class is the base class for all named ROOT classes.
virtual void AddBinContent(Int_t bin)
Increment bin content by 1.
TCanvasImp * GetCanvasImp() const
Get canvas implementation pointer if any.
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Sort the n elements of the array a of generic templated type Element.
Base class for several text objects.
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
virtual TList * GetUserInfo()
Return a pointer to the list containing user objects associated to this tree.
virtual void SetLabel(const char *label)
A Pave (see TPave) with a text centered in the Pave.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis from bin first to last.
virtual void SetEstimate(Long64_t nentries=1000000)
Set number of entries to estimate variable limits.
Class to manage histogram axis.
R__EXTERN TSystem * gSystem
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual Double_t * GetV2()
1-D histogram with an int per channel (see TH1 documentation)}
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Double_t Mean(Long64_t n, const T *a, const Double_t *w=0)
Return the weighted mean of an array a with length n.
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
char * Form(const char *fmt,...)
1-D histogram with a double per channel (see TH1 documentation)}
static constexpr double nm
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
virtual TList * GetListOfLines() const
A Pave (see TPave) with text, lines or/and boxes inside.
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
virtual void SetGridy(Int_t value=1)
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
static constexpr double s
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
virtual Long64_t GetEntries() const
Mother of all ROOT objects.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
virtual TText * DrawText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
virtual void SetEntries(Double_t n)
A TTree object has a header with a name and a title.
void SetFrameFillColor(Color_t color=1)
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
virtual void Update()
Update canvas pad buffers.
static constexpr double ns
virtual Double_t * GetV1()
void Modified(Bool_t flag=1)
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
virtual const char * GetTitle() const
Returns title of object.
const char * Data() const
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.