Utility class post-processing the file generated by TMemStat (default memstat.root) TMemStat records all the calls to malloc and free and write a TTree with the position where the memory is allocated/freed , as well as the number of bytes. To use the class TMemStat, add the following statement at the beginning of your script or program TMemStat mm("gnubuiltin"); or in an interactive session do something like: root > TMemStat mm("gnubuiltin"); root > .x somescript.C root > .q another (may be more practical way) is to modify $ROOTSYS/etc/system.rootrc and activate the variable Root.TMemStat: 1 The file collected by TMemStat is named memstat_ProcessID and can be analyzed and results shown by executing the static function Show. When TMemStat is active it recors every call to malloc/free in a ROOT Tree. You must be careful when running jobs with many millions (or more) of calls to malloc/free because the generated Tree may become very large. The TMemStat constructor TMemStat(const char* system, Int_t buffersize, Int_t maxcalls) has its 3 arguments optional: -system refers to the internal algorithm to compute the back traces. the recommended value is "gnubuiltin" -buffersize is the number of calls to malloc or free that can be stored in one memory buffer. when the buffer is full, the calls to malloc/free pointing to the same location are eliminated and not written to the final Tree. The default value 100000 is such that between 50 and 90% of the calls are eliminated depending on the application. You can set buffersize <=1 to keep every single call to malloc/free. -maxcalls can set a limit for the maximum number of calls to be registered in the Tree. The default value is 5000000. The 3 arguments can be set in $ROOTSYS/etc/system.rootrc Root.TMemStat.system gnubuiltin Root.TMemStat.buffersize 100000 Root.TMemStat.maxcalls 5000000 TMemStat::Show creates 3 canvases. -In canvas1 it displays a dynamic histogram showing for pages (10 kbytes by default) the percentage of the page used. A summary pave shows the total memory still in use when the TMemStat object goes out of scope and the average occupancy of the pages. The average occupancy gives a good indication of the memory fragmentation. When moving the mouse on this canvas, a tooltip shows the backtrace for the allocations at the address at the mouse position. -In canvas2 it displays the histogram of memory leaks in decreasing order. when moving the mouse on this canvas, a tooltip shows the backtrace for the leak in the bin below the mouse. -In canvas3 it displays the histogram of the nbigleaks largest leaks (default is 20) for each leak, the number of allocs and average alloc size is shown. Simply do: root > TMemStat::Show() or specifying arguments root > TMemStat::Show(0.1,20,"mydir/mymemstat.root"); The first argument to Show is the percentage of the time of the original job that produced the file after which the display is updated. By default update=0.1, ie 10 time intervals will be shown. The second argument is nbigleaks. if <=0 canvas2 and canvas3 are not shown The third argument is the imput file name (result of TMemStat). If this argument is omitted, Show will take the most recent file generated by TMemStat. You can restrict the address range to be analyzed via TMemStatShow::SetAddressRange You can restrict the entry range to be analyzed via TMemStatShow::SetEntryRange Author: Rene Brun 7 July 2010
virtual | ~TMemStatShow() |
void | TObject::AbstractMethod(const char* method) const |
virtual void | TObject::AppendPad(Option_t* option = "") |
virtual void | TObject::Browse(TBrowser* b) |
static TClass* | Class() |
virtual const char* | TObject::ClassName() const |
virtual void | TObject::Clear(Option_t* = "") |
virtual TObject* | TObject::Clone(const char* newname = "") const |
virtual Int_t | TObject::Compare(const TObject* obj) const |
virtual void | TObject::Copy(TObject& object) const |
virtual void | TObject::Delete(Option_t* option = "")MENU |
virtual Int_t | TObject::DistancetoPrimitive(Int_t px, Int_t py) |
virtual void | TObject::Draw(Option_t* option = "") |
virtual void | TObject::DrawClass() constMENU |
virtual TObject* | TObject::DrawClone(Option_t* option = "") constMENU |
virtual void | TObject::Dump() constMENU |
virtual void | TObject::Error(const char* method, const char* msgfmt) const |
static void | EventInfo1(Int_t event, Int_t px, Int_t py, TObject* selected) |
static void | EventInfo2(Int_t event, Int_t px, Int_t py, TObject* selected) |
virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
virtual void | TObject::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
virtual void | TObject::Fatal(const char* method, const char* msgfmt) const |
static void | FillBTString(Int_t bin, Int_t mode, TString& btstring) |
virtual TObject* | TObject::FindObject(const char* name) const |
virtual TObject* | TObject::FindObject(const TObject* obj) const |
virtual Option_t* | TObject::GetDrawOption() const |
static Long_t | TObject::GetDtorOnly() |
virtual const char* | TObject::GetIconName() const |
virtual const char* | TObject::GetName() const |
virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
static Bool_t | TObject::GetObjectStat() |
virtual Option_t* | TObject::GetOption() const |
virtual const char* | TObject::GetTitle() const |
virtual UInt_t | TObject::GetUniqueID() const |
virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
virtual ULong_t | TObject::Hash() const |
virtual void | TObject::Info(const char* method, const char* msgfmt) const |
virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
virtual void | TObject::Inspect() constMENU |
void | TObject::InvertBit(UInt_t f) |
virtual TClass* | IsA() const |
virtual Bool_t | TObject::IsEqual(const TObject* obj) const |
virtual Bool_t | TObject::IsFolder() const |
Bool_t | TObject::IsOnHeap() const |
virtual Bool_t | TObject::IsSortable() const |
Bool_t | TObject::IsZombie() const |
virtual void | TObject::ls(Option_t* option = "") const |
void | TObject::MayNotUse(const char* method) const |
virtual Bool_t | TObject::Notify() |
void | TObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const |
void | TObject::operator delete(void* ptr) |
void | TObject::operator delete(void* ptr, void* vp) |
void | TObject::operator delete[](void* ptr) |
void | TObject::operator delete[](void* ptr, void* vp) |
void* | TObject::operator new(size_t sz) |
void* | TObject::operator new(size_t sz, void* vp) |
void* | TObject::operator new[](size_t sz) |
void* | TObject::operator new[](size_t sz, void* vp) |
TMemStatShow& | operator=(const TMemStatShow&) |
virtual void | TObject::Paint(Option_t* option = "") |
virtual void | TObject::Pop() |
virtual void | TObject::Print(Option_t* option = "") const |
virtual Int_t | TObject::Read(const char* name) |
virtual void | TObject::RecursiveRemove(TObject* obj) |
void | TObject::ResetBit(UInt_t f) |
virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU |
virtual void | TObject::SavePrimitive(ostream& out, Option_t* option = "") |
static void | SetAddressRange(Long64_t nbytes = 0, Long64_t first = 0) |
void | TObject::SetBit(UInt_t f) |
void | TObject::SetBit(UInt_t f, Bool_t set) |
virtual void | TObject::SetDrawOption(Option_t* option = "")MENU |
static void | TObject::SetDtorOnly(void* obj) |
static void | SetEntryRange(Long64_t nentries = 0, Long64_t first = 0) |
static void | TObject::SetObjectStat(Bool_t stat) |
virtual void | TObject::SetUniqueID(UInt_t uid) |
static void | Show(Double_t update = 0.10000000000000001, Int_t nbigleaks = 20, const char* fname = "*") |
virtual void | ShowMembers(TMemberInspector& insp) const |
virtual void | Streamer(TBuffer&) |
void | StreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b) |
virtual void | TObject::SysError(const char* method, const char* msgfmt) const |
Bool_t | TObject::TestBit(UInt_t f) const |
Int_t | TObject::TestBits(UInt_t f) const |
TMemStatShow() | |
TMemStatShow(const TMemStatShow&) | |
virtual void | TObject::UseCurrentStyle() |
virtual void | TObject::Warning(const char* method, const char* msgfmt) const |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const |
virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
void | TObject::MakeZombie() |
static TObject::<anonymous> | TObject::kBitMask | |
static TObject::EStatusBits | TObject::kCanDelete | |
static TObject::EStatusBits | TObject::kCannotPick | |
static TObject::EStatusBits | TObject::kHasUUID | |
static TObject::EStatusBits | TObject::kInvalidObject | |
static TObject::<anonymous> | TObject::kIsOnHeap | |
static TObject::EStatusBits | TObject::kIsReferenced | |
static TObject::EStatusBits | TObject::kMustCleanup | |
static TObject::EStatusBits | TObject::kNoContextMenu | |
static TObject::<anonymous> | TObject::kNotDeleted | |
static TObject::EStatusBits | TObject::kObjInCanvas | |
static TObject::<anonymous> | TObject::kOverwrite | |
static TObject::<anonymous> | TObject::kSingleKey | |
static TObject::<anonymous> | TObject::kWriteDelete | |
static TObject::<anonymous> | TObject::kZombie |
static Long64_t | fgAddressFirst | first address to process |
static Long64_t | fgAddressN | number of addresses in bytes to process |
static TObjArray* | fgBtidlist | list of back trace ids |
static TCanvas* | fgC1 | pointer to canvas showing allocs/deallocs vs time |
static TCanvas* | fgC2 | pointer to canvas with leaks in decreasing order |
static TCanvas* | fgC3 | pointer to canvas showing the main leaks |
static Long64_t | fgEntryFirst | first entry to process |
static Long64_t | fgEntryN | number of entries to process |
static TH1D* | fgH | histogram with allocations - frees |
static TH1D* | fgHalloc | histogram with allocations |
static TH1I* | fgHdiff | histogram with diff of entry number between alloc/free |
static TH1I* | fgHentry | histogram with entry numbers in the TObjArray |
static TH1D* | fgHfree | histogram with frees |
static TH1I* | fgHleaks | histogram with leaks |
static TTree* | fgT | TMemStat Tree |
static TGToolTip* | fgTip1 | pointer to tool tip for canvas 1 |
static TGToolTip* | fgTip2 | pointer to tool tip for canvas 2 |
static Double_t* | fgV1 | pointer to V1 array of TTree::Draw (pos) |
static Double_t* | fgV2 | pointer to V2 array of TTree::Draw (nbytes) |
static Double_t* | fgV3 | pointer to V3 array of TTree::Draw (time) |
static Double_t* | fgV4 | pointer to V4 array of TTree::Draw (btid) |
specify a memory address range to process (static function). This function can be used to restrict the range of memory addresses to be analyzed. For example whem TmemStat is run on a 64 bits machine and the results visualized on a 32 bits machine, it might be necessary to restrict the analysis range to the addresses below 2 Gigabytes, eg TMemStatShow::SetMemoryRange(500000000,0); //analyse only the first 500 MBytes -first : first address to process (default is 0) -nbytes : number of addresses in bytes to process starting at first if 0 (default), then all addresses are processed
specify a range of entries to process (static function) -first : first entry to process (default is 0) -nentries : number of entries to process starting at first if 0 (default), then all entries are processed call this function when the amount of data collected in the Tree is large and therefore making the analysis slow.
function called by TMemStat::Show Open the memstat data file, then call TTree::Draw to precompute the arrays of positions and nbytes per entry. update is the time interval in the data file in seconds after which the display is updated. For example is the job producing the memstat.root file took 100s to execute, an update of 0.1s will generate 1000 time views of the memory use. the histogram hbigleaks will contain the nbigleaks largest leaks if fname=="*" (default), the most recent file memstat*.root will be taken.
static: draw the tooltip showing the backtrace for the allocatios histogram
static: draw the tooltip showing the backtrace for the histogram of leaks
static: fill btstring with the traceback corresponding to entry in T btstring must be initialized in calling function