106 TTree *TMemStatShow::fgT = 0;
107 TH1D *TMemStatShow::fgHalloc = 0;
108 TH1D *TMemStatShow::fgHfree = 0;
109 TH1D *TMemStatShow::fgH = 0;
110 TH1I *TMemStatShow::fgHleaks = 0;
111 TH1I *TMemStatShow::fgHentry = 0;
112 TH1I *TMemStatShow::fgHdiff = 0;
121 TCanvas *TMemStatShow::fgC1 = 0;
122 TCanvas *TMemStatShow::fgC2 = 0;
123 TCanvas *TMemStatShow::fgC3 = 0;
176 if (!fname || strlen(fname) <5 || strstr(fname,
"*")) {
180 fname = strstr(s.
Data()+ns-25,
"memstat");
182 printf(
"Analyzing file: %s\n",fname);
185 printf(
"Cannot open file %s\n",fname);
190 printf(
"cannot find the TMemStat TTree named T in file %s\n",fname);
194 printf(
"Illegal update value %g, changed to 0.01\n",update);
197 if (update < 0.001)
printf(
"Warning update parameter is very small, processing may be slow\n");
203 printf(
"TMemStat::Show info: you are running on a machine with %d free MBytes of memory\n",nfree);
208 if (2*8*nentries > 4*nfreebytes) {
209 nentries = 4*nfreebytes/16;
210 printf(
"not enough memory, restricting analysis to %lld entries\n",nentries);
218 printf(
"TMemStatShow::Show will analyze only %lld bytes in its first pass\n",ivmax);
227 if (ne < nentries) nentries = ne;
229 printf(
"sel: ivmin=%lld, ivmax=%lld, nentries=%lld\n",ivmin,ivmax,nentries);
230 nsel =
fgT->
Draw(
"pos:nbytes:time:btid",
246 ivmin = ivmin -ivmin%bw;
247 ivmax = ivmin+bw*
nbins;
249 printf(
"==>The data Tree contains %lld entries with addresses in range[%lld,%lld]\n",nsel,ivmin,ivmax);
251 ne = 1000000LL*nfree/32LL;
257 nsel =
fgT->
Draw(
"pos:nbytes:time:btid",
268 ivmin = ivmin -ivmin%bw;
269 ivmax = ivmin+bw*
nbins;
270 printf(
"==>Address range or/and Entry range is too large\n");
271 printf(
"==>restricting the analysis range to [%lld,%lld] and %lld entries\n",ivmin,ivmax,ne);
272 printf(
"==>you can restrict the address range with TMemStatShow::SetAddressRange\n");
273 printf(
"==>you can restrict the entries range with TMemStatShow::SetEntryRange\n");
275 update *= 0.0001*
fgV3[nsel-1];
279 if (!nbold || !ientry) {
280 printf(
"you do not have enough memory to run, %lld bytes needed\n",12*nvm);
283 memset(nbold,0,nvm*8);
284 memset(ientry,0,nvm*4);
286 TH1D *
h =
new TH1D(
"h",
Form(
"%s;pos;per cent of pages used",fname),nbins,ivmin,ivmax);
293 fgHalloc =
new TH1D(
"fgHalloc",
Form(
"%s;pos;number of mallocs",fname),nbins,ivmin,ivmax);
294 fgHfree =
new TH1D(
"fgHfree",
Form(
"%s;pos;number of frees",fname),nbins,ivmin,ivmax);
323 for (i=0;i<nsel;i++) {
327 time = 0.0001*
fgV3[i];
329 if (bin<1 || bin>nbins)
continue;
334 if (dbin > nbytes) dbin = nbytes;
338 nb =
Int_t((nbytes-dbin)/dv);
339 if (bin+nb >nbins) nb = nbins-bin;
342 rest = nbytes-nb*dv-dbin;
346 if (nbold[ipos] == 0) {
351 nbold[ipos] = nbytes;
354 nbytes = nbold[ipos];
355 if (bin+nb >nbins) nb = nbins-bin;
356 nbold[ipos] = 0; nleaks--;
358 if (nbytes <= 0)
continue;
360 if (dbin > nbytes) dbin = nbytes;
363 nb =
Int_t((nbytes-dbin)/dv);
364 if (bin+nb >nbins) nb = nbins-bin;
367 rest = nbytes-nb*dv-dbin;
371 if (time -updateLast > update) {
387 Double_t occupancy = mbytes/(nonEmpty*0.01*dv);
388 pvt->
AddText(
Form(
"memory used = %g Mbytes",mbytes*1e-6));
389 pvt->
AddText(
Form(
"page occupancy = %f per cent",occupancy));
390 pvt->
AddText(
"(for non empty pages only)");
398 if (nleaks < 0) nleaks=0;
399 Int_t nlmax = nleaks;
408 ileaks[nleaks] = (
Int_t)nbold[
ii];
409 entry[nleaks] = ientry[
ii];
411 if (nleaks > nlmax)
break;
415 fgHentry =
new TH1I(
"fgHentry",
"leak entry index",nleaks,0,nleaks);
416 fgHleaks =
new TH1I(
"fgHleaks",
"leaks;leak number;nbytes in leak",nleaks,0,nleaks);
417 for (
Int_t k=0;k<nleaks;k++) {
418 Int_t kk = lindex[k];
439 fgC1->
Connect(
"ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
440 "TMemStatShow", 0,
"EventInfo1(Int_t, Int_t, Int_t, TObject*)");
441 if (nbigleaks <= 0)
return;
461 fgC2->
Connect(
"ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
462 "TMemStatShow", 0,
"EventInfo2(Int_t, Int_t, Int_t, TObject*)");
476 TH1I *htotleaks =
new TH1I(
"htotleaks",
"main leaks sorted by btids",100,0,0);
478 for (l=1;l<=nleaks;l++) {
484 if (nbigleaks > 30) tsize = 0.02;
490 htotleaks->
Draw(
"hbar2 y+");
497 Double_t dy = (ytop-ylow)/nbigleaks;
508 for (
Int_t lb=1;lb<=nbigleaks;lb++) {
511 Int_t nchlabel = strlen(label);
514 for (l=1;l<=nleaks;l++) {
518 if (!strncmp(btstring.
Data()+2,label,nchlabel)) nl++;
520 if (btstring.
Length() == 0) nl++;
526 if (lb == 1) tnl2.
DrawText(xr2,yr,
Form(
"%d bytes/alloc",nbmean));
529 tnl.
DrawText(xr,ytop+0.015,
"nallocs");
550 while (bin <= bin1) {
563 for (
Int_t i=0;i<nsel;i++) {
564 if (
fgV2[i] < 0)
continue;
624 for (
Int_t i=0;i<nbt;i++) {
629 Int_t nch = strlen(title);
630 if (nch < 10)
continue;
631 if (strstr(title,
"malloc"))
continue;
632 if (strstr(title,
"memstat"))
continue;
633 if (strstr(title,
"TMemStatHook"))
continue;
634 char *
bar = strchr(title+5,
'|');
635 if (!bar) bar =
title;
637 if (strstr(bar,
"operator new"))
continue;
638 if (strstr(bar,
"libMemStat"))
continue;
639 if (strstr(bar,
"G__Exception"))
continue;
642 if (btstring.
Length() > 80)
return;
virtual Double_t * GetV3()
static void FillBTString(Int_t bin, Int_t mode, TString &btstring)
Static: fill btstring with the traceback corresponding to entry in T btstring must be initialized in ...
virtual const char * GetTitle() const
Returns title of object.
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.
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
static void Show(Double_t update=0.1, Int_t nbigleaks=20, const char *fname="*")
Function called by TMemStat::Show Open the memstat data file, then call TTree::Draw to precompute the...
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
static TObjArray * fgBtidlist
virtual void SetMaximum(Double_t maximum=-1111)
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Set option(s) to draw axis with labels.
virtual Double_t * GetV4()
const char * GetBinLabel(Int_t bin) const
Return label for bin.
R__EXTERN TStyle * gStyle
virtual TString GetFromPipe(const char *command)
Execute command and return output in TString.
static TGToolTip * fgTip2
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 Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual void SetMinimum(Double_t minimum=-1111)
virtual TList * GetListOfLines() const
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
static void SetEntryRange(Long64_t nentries=0, Long64_t first=0)
Specify a range of entries to process (static function)
static Long64_t fgAddressN
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
const char * Data() const
Float_t GetTopMargin() const
Float_t GetRightMargin() const
Float_t GetBottomMargin() const
virtual Long64_t GetSelectedRows()
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.
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Base class for several text objects.
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
virtual void SetLogx(Int_t value=1)
Set Lin/Log scale for X.
virtual TList * GetUserInfo()
Return a pointer to the list containing user objects associated to this tree.
virtual void SetTextAlign(Short_t align=11)
virtual void SetLabel(const char *label)
A Pave (see TPave) with a text centered in the Pave.
static Long64_t fgEntryFirst
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...
static void EventInfo2(Int_t event, Int_t px, Int_t py, TObject *selected)
Static: draw the tooltip showing the backtrace for the histogram of leaks.
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.
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual void SetFillColor(Color_t fcolor)
virtual Double_t * GetV2()
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
1-D histogram with a 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...
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)}
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels The size is expressed in per cent of the pad width.
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Float_t GetLeftMargin() const
TCanvasImp * GetCanvasImp() const
Get canvas implementation pointer if any.
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)
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
static void SetAddressRange(Long64_t nbytes=0, Long64_t first=0)
Specify a memory address range to process (static function).
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
T MaxElement(Long64_t n, const T *a)
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
static Long64_t fgAddressFirst
static void EventInfo1(Int_t event, Int_t px, Int_t py, TObject *selected)
Static: draw the tooltip showing the backtrace for the allocatios histogram.
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
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...
virtual TText * DrawText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
Double_t AbsPixeltoX(Int_t px)
virtual void SetTextColor(Color_t tcolor=1)
virtual void SetEntries(Double_t n)
virtual Long64_t GetEntries() const
A TTree object has a header with a name and a title.
void SetFrameFillColor(Color_t color=1)
virtual int GetMemInfo(MemInfo_t *info) const
Returns ram and swap memory usage info into the MemInfo_t structure.
virtual void SetTextSize(Float_t tsize=1)
TObject * At(Int_t idx) const
virtual void Update()
Update canvas pad buffers.
virtual Double_t * GetV1()
static TGToolTip * fgTip1
void Modified(Bool_t flag=1)
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
T MinElement(Long64_t n, const T *a)
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.