#ifndef ROOT_TMEMSTATMANAGER
#define ROOT_TMEMSTATMANAGER
#include <map>
#include <vector>
#include <memory>
#include <cstdlib>
#include "TObject.h"
#include "TTimeStamp.h"
#include "TMemStatDepend.h"
#include "TMemStatInfo.h"
class TTree;
class TMemStatStackInfo;
typedef std::vector<Int_t> IntVector_t;
typedef std::auto_ptr<TFile> TFilePtr_t;
class TMemStatManager: public TObject
{
struct TMemInfo_t {
void *fAddress;
size_t fSize;
Int_t fStackIndex;
};
struct TMemTable_t {
Int_t fAllocCount;
Int_t fMemSize;
Int_t fTableSize;
Int_t fFirstFreeSpot;
TMemInfo_t *fLeaks;
};
struct TDeleteTable_t {
Int_t fAllocCount;
Int_t fTableSize;
TMemInfo_t *fLeaks;
};
public:
typedef std::vector<TMemStatCodeInfo> CodeInfoContainer_t;
enum EStatusBits {
kUserDisable = BIT(18),
kStatDisable = BIT(16),
kStatRoutine = BIT(17)
};
enum EDumpTo { kTree, kSysTree };
TMemStatManager();
virtual ~TMemStatManager();
void Enable();
void Disable();
void SetAutoStamp(UInt_t sizeMem, UInt_t n, UInt_t max) {
fAutoStampSize = sizeMem;
fAutoStampN = n;
fAutoStampDumpSize = max;
}
void AddStamps(const char * stampname = 0);
static void SAddStamps(const Char_t * stampname);
static TMemStatManager* GetInstance();
static void Close();
TMemStatInfoStamp &AddStamp();
TMemStatCodeInfo &GetCodeInfo(void *address);
UInt_t GetCodeInfoIndex(void *address) {
return fCodeInfoMap[address];
}
void DumpTo(EDumpTo _DumpTo, Bool_t _clearStamps = kTRUE, const char * _stampName = 0);
public:
typedef void (*StampCallback_t)(const Char_t * desription);
IntVector_t fSTHashTable;
Int_t fCount;
Int_t fStampNumber;
std::vector<TMemStatStackInfo> fStackVector;
std::vector<TMemStatInfoStamp> fStampVector;
std::vector<TTimeStamp> fStampTime;
CodeInfoContainer_t fCodeInfoArray;
std::map<const void*, UInt_t> fCodeInfoMap;
Int_t fDebugLevel;
TMemStatManager::StampCallback_t fStampCallBack;
void SetUseGNUBuildinBacktrace(Bool_t _NewVal) {
fUseGNUBuildinBacktrace = _NewVal;
}
protected:
TMemStatDepend::MallocHookFunc_t fPreviousMallocHook;
TMemStatDepend::FreeHookFunc_t fPreviousFreeHook;
void Init();
TMemStatStackInfo *STAddInfo(Int_t size, void **stackptrs);
TMemStatStackInfo *STFindInfo(Int_t size, void **stackptrs);
void RehashLeak(Int_t newSize);
void *AddPointer(size_t size, void *ptr = 0);
void FreePointer(void *p);
static void *AllocHook(size_t size, const void* );
static void FreeHook(void* ptr, const void* );
TMemStatInfoStamp fLastStamp;
TMemStatInfoStamp fCurrentStamp;
UInt_t fAutoStampSize;
UInt_t fAutoStampN;
UInt_t fAutoStampDumpSize;
Int_t fMinStampSize;
Int_t fSize;
TMemTable_t **fLeak;
Int_t fAllocCount;
TDeleteTable_t fMultDeleteTable;
TFilePtr_t fDumpFile;
TTree *fDumpTree;
TTree *fDumpSysTree;
static TMemStatManager *fgInstance;
static void *fgStackTop;
void FreeHashtable() {
if (!fLeak)
return;
for (Int_t i = 0; i < fSize; ++i)
free(fLeak[i]);
free(fLeak);
}
Bool_t fUseGNUBuildinBacktrace;
ClassDef(TMemStatManager, 1)
};
#endif
Last change: Fri Jul 4 14:51:19 2008
Last generated: 2008-07-04 14:51
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.