ROOT
6.07/01
Reference Guide
|
Storage manager.
The storage manager works best in conjunction with the custom ROOT new and delete operators defined in the file NewDelete.cxx (libNew.so). 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 libNew.so) 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 occur.
Set the compile option R__NOSTATS to de-activate all memory checking and statistics gathering in the system.
Definition at line 34 of file TStorage.h.
Public Member Functions | |
virtual | ~TStorage () |
Static Public Member Functions | |
static ULong_t | GetHeapBegin () |
static ULong_t | GetHeapEnd () |
static FreeHookFun_t | GetFreeHook () |
static void * | GetFreeHookData () |
return static free hook data More... | |
static size_t | GetMaxBlockSize () |
static void * | Alloc (size_t size) |
Allocate a block of memory, that later can be resized using TStorage::ReAlloc(). More... | |
static void | Dealloc (void *ptr) |
De-allocate block of memory, that was allocated via TStorage::Alloc(). More... | |
static void * | ReAlloc (void *vp, size_t size) |
Reallocate (i.e. More... | |
static void * | ReAlloc (void *vp, size_t size, size_t oldsize) |
Reallocate (i.e. More... | |
static char * | ReAllocChar (char *vp, size_t size, size_t oldsize) |
Reallocate (i.e. More... | |
static Int_t * | ReAllocInt (Int_t *vp, size_t size, size_t oldsize) |
Reallocate (i.e. More... | |
static void * | ObjectAlloc (size_t size) |
Used to allocate a TObject on the heap (via TObject::operator new()). More... | |
static void * | ObjectAllocArray (size_t size) |
Used to allocate array of TObject on the heap (via TObject::operator new[]()). More... | |
static 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. More... | |
static void | ObjectDealloc (void *vp) |
Used to deallocate a TObject on the heap (via TObject::operator delete()). More... | |
static void | ObjectDealloc (void *vp, void *ptr) |
Used to deallocate a TObject on the heap (via TObject::operator delete(void*,void*)). More... | |
static void | EnterStat (size_t size, void *p) |
Register a memory allocation operation. More... | |
static void | RemoveStat (void *p) |
Register a memory free operation. More... | |
static void | PrintStatistics () |
Print memory usage statistics. More... | |
static void | SetMaxBlockSize (size_t size) |
static void | SetFreeHook (FreeHookFun_t func, void *data) |
Set a free handler. More... | |
static void | SetReAllocHooks (ReAllocFun_t func1, ReAllocCFun_t func2) |
Set a custom ReAlloc handlers. More... | |
static void | SetCustomNewDelete () |
set the has custom delete flag More... | |
static void | EnableStatistics (int size=-1, int ix=-1) |
Enable memory usage statistics gathering. More... | |
static Bool_t | HasCustomNewDelete () |
return the has custom delete flag More... | |
static void | AddToHeap (ULong_t begin, ULong_t end) |
add a range to the heap More... | |
static Bool_t | IsOnHeap (void *p) |
is object at p in the heap? More... | |
static Bool_t | FilledByObjectAlloc (UInt_t *member) |
Static Private Attributes | |
static size_t | fgMaxBlockSize |
static FreeHookFun_t | fgFreeHook |
static void * | fgFreeHookData |
static ReAllocFun_t | fgReAllocHook |
static ReAllocCFun_t | fgReAllocCHook |
static Bool_t | fgHasCustomNewDelete |
static const UInt_t | kObjectAllocMemValue = 0x99999999 |
#include <TStorage.h>
|
inlinevirtual |
Definition at line 47 of file TStorage.h.
add a range to the heap
Definition at line 490 of file TStorage.cxx.
Allocate a block of memory, that later can be resized using TStorage::ReAlloc().
Definition at line 146 of file TStorage.cxx.
Referenced by TOrdCollection::Init(), TObjArray::Init(), TGWin32::TGWin32(), and TGX11::TGX11().
De-allocate block of memory, that was allocated via TStorage::Alloc().
Definition at line 164 of file TStorage.cxx.
Referenced by TOrdCollection::Clear(), TGWin32::CloseDisplay(), TOrdCollection::Delete(), TObjArray::Init(), TGX11::~TGX11(), TObjArray::~TObjArray(), and TOrdCollection::~TOrdCollection().
|
static |
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.
Definition at line 433 of file TStorage.cxx.
Referenced by TROOT::InitSystem().
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.
Definition at line 93 of file TStorage.cxx.
Definition at line 87 of file TStorage.h.
Referenced by ClassImp(), and TObject::TObject().
|
inlinestatic |
Definition at line 116 of file TStorage.h.
|
static |
return static free hook data
Definition at line 465 of file TStorage.cxx.
|
static |
Definition at line 446 of file TStorage.cxx.
|
static |
Definition at line 455 of file TStorage.cxx.
|
inlinestatic |
Definition at line 112 of file TStorage.h.
Referenced by EnterStat().
|
static |
return the has custom delete flag
Definition at line 473 of file TStorage.cxx.
Referenced by TMapFile::MapToAddress(), and PrintStatistics().
is object at p in the heap?
Definition at line 498 of file TStorage.cxx.
Used to allocate a TObject on the heap (via TObject::operator new()).
Directly after this routine one can call (in the TObject ctor) TStorage::FilledByObjectAlloc() to find out if the just created object is on the heap. This technique is necessary as there is one stack per thread and we can not rely on comparison with the current stack memory position.
Definition at line 322 of file TStorage.cxx.
Referenced by TObject::operator new(), TObject::operator new[](), and TClonesArray::operator[]().
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.
Definition at line 345 of file TStorage.cxx.
Used to allocate array of TObject on the heap (via TObject::operator new[]()).
Unlike the 'singular' ObjectAlloc, we do not mark those object has being allocated on the heap as they can not be individually deleted.
Definition at line 334 of file TStorage.cxx.
Referenced by TObject::operator new[]().
Used to deallocate a TObject on the heap (via TObject::operator delete()).
Definition at line 353 of file TStorage.cxx.
Referenced by TObject::operator delete(), and TObject::operator delete[]().
Used to deallocate a TObject on the heap (via TObject::operator delete(void*,void*)).
Definition at line 362 of file TStorage.cxx.
|
static |
Print memory usage statistics.
Definition at line 389 of file TStorage.cxx.
Referenced by TROOT::~TROOT().
Reallocate (i.e.
resize) block of memory. Don't use if size is larger than old size, use ReAlloc(void *, size_t, size_t) instead.
Definition at line 177 of file TStorage.cxx.
Referenced by TGX11::AddPixmap(), TGWin32::AddPixmap(), TGX11::AddWindow(), TGWin32::AddWindow(), TGX11::CollectImageColors(), TObjArray::Expand(), TBranch::ExpandBasketArrays(), TTree::ImportClusterRanges(), TGX11::InitWindow(), TGWin32::InitWindow(), TGX11::OpenPixmap(), TGWin32::OpenPixmap(), TFPBlock::ReallocBlock(), TTree::SetAutoFlush(), and TOrdCollection::SetCapacity().
Reallocate (i.e.
resize) block of memory. Checks if current size is equal to oldsize. If not memory was overwritten.
Definition at line 216 of file TStorage.cxx.
Reallocate (i.e.
resize) array of chars. Size and oldsize are in number of chars.
Definition at line 259 of file TStorage.cxx.
Referenced by TBuffer::Expand(), TPDF::PrintFast(), TPDF::PrintStr(), and TBuffer::SetReAllocFunc().
Reallocate (i.e.
resize) array of integers. Size and oldsize are number of integers (not number of bytes).
Definition at line 289 of file TStorage.cxx.
Referenced by TBranch::ExpandBasketArrays(), TSystem::Load(), TFPBlock::ReallocBlock(), and TBasket::Update().
Register a memory free operation.
This function is only called via the custom ROOT delete operator.
Definition at line 123 of file TStorage.cxx.
|
static |
set the has custom delete flag
Definition at line 481 of file TStorage.cxx.
|
static |
Set a free handler.
Definition at line 370 of file TStorage.cxx.
Definition at line 114 of file TStorage.h.
Referenced by EnterStat().
|
static |
Set a custom ReAlloc handlers.
This function is typically called via a static object in the ROOT libNew.so shared library.
Definition at line 380 of file TStorage.cxx.
|
staticprivate |
Definition at line 38 of file TStorage.h.
Referenced by GetFreeHook(), and SetFreeHook().
|
staticprivate |
Definition at line 39 of file TStorage.h.
Referenced by GetFreeHookData(), and SetFreeHook().
|
staticprivate |
Definition at line 42 of file TStorage.h.
Referenced by HasCustomNewDelete(), ReAlloc(), and SetCustomNewDelete().
|
staticprivate |
Definition at line 37 of file TStorage.h.
Referenced by GetMaxBlockSize(), and SetMaxBlockSize().
|
staticprivate |
Definition at line 41 of file TStorage.h.
Referenced by ReAlloc(), and SetReAllocHooks().
|
staticprivate |
Definition at line 40 of file TStorage.h.
Referenced by ReAlloc(), and SetReAllocHooks().
|
staticprivate |
Definition at line 43 of file TStorage.h.
Referenced by FilledByObjectAlloc(), and ObjectAlloc().