ROOT logo
ROOT » CORE » BASE » TStorage

class TStorage


Storage manager. The storage manager works best in conjunction with
the custom ROOT new and delete operators defined in the file
NewDelete.cxx ( Only when using the custom allocation
operators will memory usage statistics be gathered using the
TStorage EnterStat(), RemoveStat(), etc. functions.
Memory checking is by default enabled (when using and
usage statistics is gathered. Using the resource (in .rootrc):
Root.MemStat one can toggle statistics gathering on or off. More
specifically on can trap the allocation of a block of memory of a
certain size. This can be specified using the resource:
Root.MemStat.size, using the resource Root.MemStat.cnt one can
specify after how many allocations of this size the trap should
Set the compile option R__NOSTATS to de-activate all memory checking
and statistics gathering in the system.

Function Members (Methods)

TStorage(const TStorage&)
static voidAddToHeap(ULong_t begin, ULong_t end)
static void*Alloc(size_t size)
static TClass*Class()
static voidDealloc(void* ptr)
static voidEnableStatistics(int size = -1, int ix = -1)
static voidEnterStat(size_t size, void* p)
static FreeHookFun_tGetFreeHook()
static void*GetFreeHookData()
static ULong_tGetHeapBegin()
static ULong_tGetHeapEnd()
static size_tGetMaxBlockSize()
static Bool_tHasCustomNewDelete()
virtual TClass*IsA() const
static Bool_tIsOnHeap(void* p)
static void*ObjectAlloc(size_t size)
static void*ObjectAlloc(size_t size, void* vp)
static voidObjectDealloc(void* vp)
static voidObjectDealloc(void* vp, void* ptr)
TStorage&operator=(const TStorage&)
static voidPrintStatistics()
static void*ReAlloc(void* vp, size_t size)
static void*ReAlloc(void* vp, size_t size, size_t oldsize)
static char*ReAllocChar(char* vp, size_t size, size_t oldsize)
static Int_t*ReAllocInt(Int_t* vp, size_t size, size_t oldsize)
static voidRemoveStat(void* p)
static voidSetCustomNewDelete()
static voidSetFreeHook(FreeHookFun_t func, void* data)
static voidSetMaxBlockSize(size_t size)
static voidSetReAllocHooks(ReAllocFun_t func1, ReAllocCFun_t func2)
virtual voidShowMembers(TMemberInspector& insp)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)

Data Members

static FreeHookFun_tfgFreeHookfunction called on free
static void*fgFreeHookDatadata used by this function
static Bool_tfgHasCustomNewDeletetrue if using ROOT's new/delete
static ULong_tfgHeapBeginbegin address of heap
static ULong_tfgHeapEndend address of heap
static size_tfgMaxBlockSizelargest block allocated
static ReAllocCFun_tfgReAllocCHookcustom ReAlloc with length check
static ReAllocFun_tfgReAllocHookcustom ReAlloc

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

void EnterStat(size_t size, void* p)
 Register a memory allocation operation. If desired one can trap an
 allocation of a certain size in case one tries to find a memory
 leak of that particular size. This function is only called via
 the ROOT custom new operators.
void RemoveStat(void* p)
 Register a memory free operation. This function is only called via
 the custom ROOT delete operator.
void * Alloc(size_t size)
 Allocate a block of memory, that later can be resized using
void Dealloc(void* ptr)
 De-allocate block of memory, that was allocated via TStorage::Alloc().
void * ReAlloc(void* vp, size_t size)
 Reallocate (i.e. resize) block of memory.
void * ReAlloc(void* vp, size_t size, size_t oldsize)
 Reallocate (i.e. resize) block of memory. Checks if current size is
 equal to oldsize. If not memory was overwritten.
char * ReAllocChar(char* vp, size_t size, size_t oldsize)
 Reallocate (i.e. resize) array of chars. Size and oldsize are
 in number of chars.
Int_t * ReAllocInt(Int_t* vp, size_t size, size_t oldsize)
 Reallocate (i.e. resize) array of integers. Size and oldsize are
 number of integers (not number of bytes).
void * ObjectAlloc(size_t size)
 Used to allocate a TObject on the heap (via TObject::operator new()).
 Directly after this routine one can call (in the TObject ctor)
 TStorage::IsOnHeap() to find out if the just created object is on
 the heap.
void * ObjectAlloc(size_t size, void* vp)
 Used to allocate a TObject on the heap (via TObject::operator new(size_t,void*))
 in position vp. vp is already allocated (maybe on heap, maybe on
 stack) so just return.
void ObjectDealloc(void* vp)
 Used to deallocate a TObject on the heap (via TObject::operator delete()).
void ObjectDealloc(void* vp, void* ptr)
 Used to deallocate a TObject on the heap (via TObject::operator delete(void*,void*)).
void SetFreeHook(FreeHookFun_t func, void* data)
 Set a free handler.
void SetReAllocHooks(ReAllocFun_t func1, ReAllocCFun_t func2)
 Set a custom ReAlloc handlers. This function is typically
 called via a static object in the ROOT shared library.
void PrintStatistics()
 Print memory usage statistics.
void EnableStatistics(int size = -1, int ix = -1)
 Enable memory usage statistics gathering. Size is the size of the memory
 block that should be trapped and ix is after how many such allocations
 the trap should happen.
ULong_t GetHeapBegin()
return begin of heap
ULong_t GetHeapEnd()
return end of heap
void * GetFreeHookData()
return static free hook data
Bool_t HasCustomNewDelete()
return the has custom delete flag
void SetCustomNewDelete()
set the has custom delete flag
void AddToHeap(ULong_t begin, ULong_t end)
add a range to the heap
Bool_t IsOnHeap(void* p)
is object at p in the heap?
size_t GetMaxBlockSize()
return max block size
void SetMaxBlockSize(size_t size)
set max block size
FreeHookFun_t GetFreeHook()
return free hook
virtual ~TStorage()
{ }