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);
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);
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");
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);
288 TAxis *axis =
h->GetXaxis();
290 h->SetFillColor(
kRed);
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;
336 h->AddBinContent(bin,100*dbin/dv);
338 nb =
Int_t((nbytes-dbin)/dv);
339 if (bin+nb >nbins) nb = nbins-bin;
340 for (j=1;j<=nb;j++)
h->AddBinContent(bin+j,100);
342 rest = nbytes-nb*dv-dbin;
343 if (rest > 0)
h->AddBinContent(bin+nb+1,100*rest/dv);
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;
361 h->AddBinContent(bin,-100*dbin/dv);
363 nb =
Int_t((nbytes-dbin)/dv);
364 if (bin+nb >nbins) nb = nbins-bin;
365 for (j=1;j<=nb;j++)
h->AddBinContent(bin+j,-100);
367 rest = nbytes-nb*dv-dbin;
368 if (rest > 0)
h->AddBinContent(bin+nb+1,-100*rest/dv);
371 if (time -updateLast >
update) {
380 for (
Int_t k=1;k<nbins;k++) {
381 w =
h->GetBinContent(k);
387 Double_t occupancy = mbytes/(nonEmpty*0.01*dv);
388 pvt->
AddText(
Form(
"memory used = %g Mbytes",mbytes*1
e-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;
406 for (
Int_t ii=0;ii<nvm;ii++) {
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;
604 TString form1 =
TString::Format(
" Leak number=%d, leaking %d bytes at entry=%d time=%gseconds\n\n",bin,nbytes,entry,time);
624 for (
Int_t i=0;i<nbt;i++) {
628 char *title = (
char*)
nm->GetTitle();
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,
'|');
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;
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,...)
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
void SetFrameFillColor(Color_t color=1)
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Float_t GetLeftMargin() const
Float_t GetBottomMargin() const
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Float_t GetRightMargin() const
Float_t GetTopMargin() const
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Class to manage histogram axis.
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
const char * GetBinLabel(Int_t bin) const
Return label for bin.
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis from bin first to last.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
TCanvasImp * GetCanvasImp() const
Get canvas implementation pointer if any.
virtual void Update()
Update canvas pad buffers.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
1-D histogram with a double per channel (see TH1 documentation)}
1-D histogram with an int per channel (see TH1 documentation)}
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Set option(s) to draw axis with labels.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
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...
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void SetEntries(Double_t n)
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
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 ...
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.
static TGToolTip * fgTip2
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.
static Long64_t fgAddressN
static TObjArray * fgBtidlist
static void SetEntryRange(Long64_t nentries=0, Long64_t first=0)
Specify a range of entries to process (static function)
static Long64_t fgEntryFirst
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...
static TGToolTip * fgTip1
static Long64_t fgAddressFirst
static void SetAddressRange(Long64_t nbytes=0, Long64_t first=0)
Specify a memory address range to process (static function).
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetTitle() const
Returns title of object.
TObject * At(Int_t idx) const
Mother of all ROOT objects.
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.
virtual void SetGridx(Int_t value=1)
virtual void SetGridy(Int_t value=1)
virtual void SetLogx(Int_t value=1)
Set Lin/Log scale for X.
void Modified(Bool_t flag=1)
Double_t AbsPixeltoX(Int_t px)
A Pave (see TPave) with a text centered in the Pave.
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
virtual void SetLabel(const char *label)
A Pave (see TPave) with text, lines or/and boxes inside.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
virtual TList * GetListOfLines() const
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.
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
virtual int GetMemInfo(MemInfo_t *info) const
Returns ram and swap memory usage info into the MemInfo_t structure.
virtual TString GetFromPipe(const char *command)
Execute command and return output in TString.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Base class for several text objects.
virtual TText * DrawText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
A TTree represents a columnar dataset.
virtual Long64_t GetSelectedRows()
virtual Double_t * GetV3()
virtual Long64_t GetEntries() const
virtual void SetEstimate(Long64_t nentries=1000000)
Set number of entries to estimate variable limits.
virtual Double_t * GetV1()
virtual TList * GetUserInfo()
Return a pointer to the list containing user objects associated to this tree.
virtual Double_t * GetV4()
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
virtual Double_t * GetV2()
static constexpr double bar
static constexpr double nm
static constexpr double s
static constexpr double ns
T MinElement(Long64_t n, const T *a)
Return minimum of array a of length n.
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
T MaxElement(Long64_t n, const T *a)
Return maximum of array a of length n.