class TMemStat: public TObject


The TMemStat class

TMemStat - a class for visualization of the memory usage.
Principle: Hook functions for malloc and free are used. All calls to malloc and free are caught and the statistical information is collected. The information is collected per stack trace (Unique identifier and per functions).
Following information are collected as function of time:
  • Total number of allocations
  • Total allocation size
  • Allocation count
  • Allocation size
How to use it:
To create a memstat object use the following:
    TMemStat memstat("new");
Possible options:
  • "new" - Start new data collection. In the current release a hard-codded "memstat.root" file will be created or overwritten if exists.
  • "read" - "read" - analyze previously collected data.
  • "gnubuildin" - if declared, then TMemStat will use gcc build-in function, otherwise glibc backtrace will be used.
A user may want to request for adding the named memory stamp:
    memstat.AddStamp("STEMPNAME")
The file "memstat.root" is created after destruction of object.
This class supports following functions for standard user:
  • Report
  • Draw
  • SelectCode(libname, functionname)
  • SelectStack()
The various format options to draw a Graph can be accessed calling
    TMemStat memstat;
    memstat.Report("?")
Supported options for TMemStat::Report:
  • order : 0 - increasing 1 - decreasing
  • sortstat : 0 - TotalAllocCount 1 - TotalAlocSize 2 - AllocCount 3 - AllocSize
  • sortstamp : 0 - Current 1 - MaxSize 2 - MaxCount
  • sortdeep : (0-inf) number of info to print
  • stackdeep : (0-inf) deepnes of stack
  • Example : order 0 sortstat 3 sortstamp 0 sortdeep 10 stackdeep 5 maxlength 50
The picture below gives an example:


Function Members (Methods)

public:
TMemStat(Option_t* option = "read")
virtual~TMemStat()
voidTObject::AbstractMethod(const char* method) const
voidAddStamp(const char* stampName)
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual voidDraw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
voidGetFillSelection(TMemStat::Selection_t* _Container, TMemStat::ESelection _Selection) const
virtual const char*TObject::GetIconName() const
UInt_tGetMaxStringLength() const
virtual const char*TObject::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*GetOption() const
UInt_tGetSortDeep() const
UInt_tGetStackDeep() const
TObjArray*GetStampList()
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
voidMakeHisMemoryStamp(Int_t topDiff)
voidMakeHisMemoryTime()
voidMakeReport(const char* lib = "", const char* fun = "", Option_t* option = NULL, const char* fileName = "")
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::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)
TObject&TObject::operator=(const TObject& rhs)
virtual voidPaint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
voidPrintCode(Int_t nentries = 10) const
voidPrintCodeWithID(UInt_t index) const
voidPrintStack(Int_t nentries = 10, UInt_t deep = 1) const
voidPrintStackWithID(UInt_t _id, UInt_t _deep = 0) const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidReport(Option_t* option = "")
voidTObject::ResetBit(UInt_t f)
voidResetSelection()
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidSelectCode(const char* contlib = "", const char* contfunction = "", TMemStat::OperType oType = kOR)
voidSelectStack(TMemStat::OperType oType = kOR)
voidSetAutoStamp(Int_t autoStampSize = 2000000, Int_t autoStampAlloc = 200000)
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidSetCurrentStamp(const char* stampName)
voidSetCurrentStamp(const TObjString& stampName)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
static voidTObject::SetObjectStat(Bool_t stat)
voidSetSortDeep(UInt_t NewVal)
voidSetSortStamp(TMemStat::StampType NewVal)
voidSetSortStat(TMemStat::StatType NewVal)
voidSetStackDeep(UInt_t NewVal)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
voidSortCode(TMemStat::StatType sortType, TMemStat::StampType stampType)
voidSortStack(TMemStat::StatType sortType, TMemStat::StampType stampType)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
private:
virtual Int_tDistancetoPrimitive(Int_t px, Int_t py)
Bool_tEnabledCode(const TMemStatCodeInfo& info) const
virtual voidExecuteEvent(Int_t event, Int_t px, Int_t py)
Bool_tGetMemStat(const char* fname, Int_t entry)
voidMakeCodeArray()
TGraph*MakeGraph(TMemStat::StatType statType, Int_t id, Int_t type, Double_t& xmax, Double_t& ymax)
TObjArray*MakeGraphCode(TMemStat::StatType statType, Int_t nentries)
TObjArray*MakeGraphStack(TMemStat::StatType statType, Int_t nentries)
voidMakeStackArray()
voidMakeStampsText()
voidProcessOption(Option_t* option)
voidRefreshSelect()

Data Members

public:
enum ESelection { kFunction
kLibrary
};
enum StatType { kTotalAllocCount
kAllocCount
kTotalAllocSize
kAllocSize
kUndef
};
enum StampType { kCurrent
kMaxSize
kMaxCount
};
enum OperType { kAND
kOR
kNOT
};
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
private:
TObjArray*fArrayarray of objects to draw
TObjArray*fArrayGraphicsarray of graphic objects
IntVector_tfArrayIndexesindexes of selected objects
TObjArrayfDisablePrintCodedisable printing for libraries
TObjArrayfDisablePrintLibdisable printing for libraries
auto_ptr<TFile>fFilecurrent file with information - stamps
Bool_tfIsActiveis object attached to MemStat
TMemStatManager*fManagercurrent MemStatManager
UInt_tfMaxStringLengthmax length of information string
TStringfOptioncurrent options
Bool_tfOrdersorting order
Int_tfSelectedindex of selected object
TBits*fSelectedCodeBitmapbitmask of selected items - code
UIntVector_tfSelectedCodeIndexvector of indexes of selected items - code
TBits*fSelectedStackBitmapbitmask of selected items - stack
UIntVector_tfSelectedStackIndexvector of indexes of selected items - stack
UInt_tfSortDeepdeepnes of the information to be print - draw
TMemStat::StampTypefSortStampsorting stamp type
TMemStat::StatTypefSortStatsorting statistic type
UInt_tfStackDeepdeepnes of the stack information
TMemStatInfoStamp*fStackSummarysummary information for selected stack
TObjArray*fStampArrayarray of stamp names
TTree*fTreecurrent tree with inforamtion - stamps
TTree*fTreeSystree with system information

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TMemStat(Option_t* option = "read")
 Supported options:
    "new" - start to collect memory allocations stamps
    "read" - analyze previously collected data
    "gnubuildin" - if declared, then TMemStat will use gcc build-in function,
                      otherwise glibc backtrace will be used

 Default: "read"
 Note: Currently TMemStat uses a hard-coded output file name (for writing/reading) = "memstat.root";
~TMemStat()
 destructor
void AddStamp(const char* stampName)
 Add named stamp to the file
void Draw(Option_t* option = "")
 Draw the memory statistic
 call ::Report("?") to see possible options and meaning
void GetFillSelection(TMemStat::Selection_t* _Container, TMemStat::ESelection _Selection) const
 TODO: Comment me
TObjArray* GetStampList()
 TODO: Comment me
void MakeReport(const char* lib = "", const char* fun = "", Option_t* option = NULL, const char* fileName = "")
 make report for library
void MakeHisMemoryStamp(Int_t topDiff)
draw histogram of memory usage as function of stamp name
 NOT IMPLEMENTED YET
void MakeHisMemoryTime()
 Make dump of memory usage versus time
void Paint(Option_t* option = "")
 Paint function
void PrintCode(Int_t nentries = 10) const
 Print information about n selected functions
 If the number of function selected is bigger than number n
 the only top (sorted accoring some creteria,) n are displayed
 e.g draw.SortCode(TMemStat::kAllocSize,TMemStat::kCurrent);
void PrintCodeWithID(UInt_t index) const
 print information for code with ID
void PrintStack(Int_t nentries = 10, UInt_t deep = 1) const
 Print information about n selected stack traces
 If the number of function selected is bigger than number n
 the only top (sorted accoring some creteria,) n are displayed
 e.g draw.SortCode(TMemStat::kAllocSize,TMemStat::kCurrent);
void PrintStackWithID(UInt_t _id, UInt_t _deep = 0) const
 print stack information for code with ID
 NOTE: if _deep is 0, then we use fStackDeep
void Report(Option_t* option = "")
 Report function
 Supported options:

 order     : 0 - increasing 1 - decreasing
 sortstat  : 0 - TotalAllocCount 1 -  TotalAlocSize  2 - AllocCount 3 - AllocSize
 sortstamp : 0 - Current 1 -  MaxSize  2 - MaxCount
 sortdeep  : (0-inf) number of info to print
 stackdeep : (0-inf) deepnes of stack
 Example   : order 0 sortstat 3 sortstamp 0 sortdeep 10 stackdeep 5 maxlength 50
void ResetSelection()
 reset all selections
void SetAutoStamp(Int_t autoStampSize = 2000000, Int_t autoStampAlloc = 200000)
 Change default values of the auto stamping
   autoStampSize  [in] - size of invoking STAMPs
   autoStampAlloc [in] - a number of allocations
void SetCurrentStamp(const char *stampName)
 Getvalues for iven stamp
void SetCurrentStamp(const TObjString &stampName)
 TODO: Comment me
void SelectCode(const char* contlib = "", const char* contfunction = "", TMemStat::OperType oType = kOR)
 select code with given mask
 contlib       - select only code containing contlib in library path
 contfunction  - select only code with function name containing contfunction
 oType         - logiacal operation - AND and Or is suported
 By default all code is enabled
void SelectStack(TMemStat::OperType oType = kOR)
 select stack containig the selected code
 oType - And and OR is supported (AND, OR in respect with previous selection)
void SortCode(TMemStat::StatType sortType, TMemStat::StampType stampType)
 sort code according statistical criteria
 sortType
 stampType
void SortStack(TMemStat::StatType sortType, TMemStat::StampType stampType)
 sort code according statistical criteria
 sortType
 stampType
Int_t DistancetoPrimitive(Int_t px, Int_t py)
 Return distance of the mouse to the TMemStat object
Bool_t GetMemStat(const char* fname, Int_t entry)
 Get memstat from tree
Bool_t EnabledCode(const TMemStatCodeInfo& info) const
 Private function
 disable printing of the predefined code sequence
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
 function called when clicking with the mouse on a TMemStat object
void MakeCodeArray()
   PRIVATE: make code index accoring tbit mask
void MakeStackArray()
   PRIVATE: make code index accoring tbit mask
TObjArray * MakeGraphCode(TMemStat::StatType statType, Int_t nentries)
 make array of graphs
TObjArray * MakeGraphStack(TMemStat::StatType statType, Int_t nentries)
 make array of graphs
TGraph * MakeGraph(TMemStat::StatType statType, Int_t id, Int_t type, Double_t& xmax, Double_t& ymax)
 Make graph
void MakeStampsText()
 Make a text description of the stamps
 create a array of TText objects
void ProcessOption(Option_t* option)
 PRIVATE function
 process user option string for printing
void RefreshSelect()
 TODO: Comment me
const Option_t* GetOption()
UInt_t GetStackDeep()
UInt_t GetSortDeep()
UInt_t GetMaxStringLength()
void SetSortStat(TMemStat::StatType NewVal)
void SetSortStamp(TMemStat::StampType NewVal)
void SetStackDeep(UInt_t NewVal)
void SetSortDeep(UInt_t NewVal)

Author: D.Bertini and M.Ivanov 18/06/2007 -- Anar Manafov (A.Manafov@gsi.de) 28/04/2008
Last change: root/memstat:$Name$:$Id: TMemStat.h 24366 2008-06-19 09:50:29Z anar $
Last generated: 2008-06-25 08:49
Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.