42 #if !defined(R__NOSTATS) 45 # define MEM_CHECKOBJECTPOINTERS 48 #if defined(MEM_STAT) && !defined(MEM_DEBUG) 54 # define storage_size(p) ((size_t)(((size_t*)p)[-1])) 56 # define storage_size(p) ((size_t)(((int*)p)[-2])) 59 # define storage_size(p) ((size_t)0) 103 if (!gMemStatistics)
return;
112 if (gTraceIndex >= gTraceCapacity) {
113 gTraceCapacity = gTraceCapacity*2;
116 gTraceArray[gTraceIndex++] = p;
118 if (size >= kObjMaxSize)
122 gAllocatedTotal += size;
154 static const char *where =
"TStorage::Alloc";
157 void *vp = ::operator
new[](size);
159 void *vp = ::operator
new(size);
173 ::operator
delete[](ptr);
175 ::operator
delete(ptr);
185 ::Obsolete(
"ReAlloc(void*,size_t)",
"v5-34-00",
"v6-02-00");
186 ::Info(
"ReAlloc(void*,size_t)",
"please use ReAlloc(void*,size_t,size_t)");
196 static const char *where =
"TStorage::ReAlloc";
199 void *vp = ::operator
new[](size);
201 void *vp = ::operator
new(size);
209 memmove(vp, ovp, size);
211 ::operator
delete[](ovp);
213 ::operator
delete(ovp);
232 static const char *where =
"TStorage::ReAlloc";
238 void *vp = ::operator
new[](size);
240 void *vp = ::operator
new(size);
248 if (size > oldsize) {
249 memcpy(vp, ovp, oldsize);
250 memset((
char*)vp+oldsize, 0, size-oldsize);
252 memcpy(vp, ovp, size);
254 ::operator
delete[](ovp);
256 ::operator
delete(ovp);
267 static const char *where =
"TStorage::ReAllocChar";
282 if (size > oldsize) {
283 memcpy(vp, ovp, oldsize);
284 memset((
char*)vp+oldsize, 0, size-oldsize);
286 memcpy(vp, ovp, size);
297 static const char *where =
"TStorage::ReAllocInt";
301 vp =
new Int_t[size];
309 vp =
new Int_t[size];
312 if (size > oldsize) {
313 memcpy(vp, ovp, oldsize*
sizeof(
Int_t));
314 memset((
Int_t*)vp+oldsize, 0, (size-oldsize)*
sizeof(
Int_t));
316 memcpy(vp, ovp, size*
sizeof(
Int_t));
330 void* space = ::operator
new(sz);
342 void* space = ::operator
new(sz);
362 ::operator
delete(vp);
373 #ifdef R__SIZEDDELETE 380 ::operator
delete(vp, size);
411 #if defined(MEM_DEBUG) && defined(MEM_STAT) 417 Printf(
"Heap statistics");
418 Printf(
"%12s%12s%12s%12s",
"size",
"alloc",
"free",
"diff");
419 Printf(
"================================================");
429 Printf(
"------------------------------------------------");
435 Printf(
"------------------------------------------------");
440 Printf(
"================================================");
457 int idum = size;
int iidum = ix;
465 ::Obsolete(
"GetHeapBegin()",
"v5-34-00",
"v6-02-00");
474 ::Obsolete(
"GetHeapBegin()",
"v5-34-00",
"v6-02-00");
509 ::Obsolete(
"AddToHeap(ULong_t,ULong_t)",
"v5-34-00",
"v6-02-00");
517 ::Obsolete(
"IsOnHeap(void*)",
"v5-34-00",
"v6-02-00");
static void Dealloc(void *ptr)
De-allocate block of memory, that was allocated via TStorage::Alloc().
void *(* ReAllocFun_t)(void *, size_t)
Namespace for new ROOT classes and functions.
void Fatal(const char *location, const char *msgfmt,...)
static const UInt_t kObjectAllocMemValue
static ULong_t GetHeapBegin()
static Bool_t MemCheck()
Return kTRUE if the memory leak checker is on.
static void * ObjectAlloc(size_t size)
Used to allocate a TObject on the heap (via TObject::operator new()).
static const char * gSpaceErr
static ULong_t GetHeapEnd()
void Obsolete(const char *function, const char *asOfVers, const char *removedFromVers)
Use this function to declare a function obsolete.
static ReAllocCFun_t fgReAllocCHook
static void AddToHeap(ULong_t begin, ULong_t end)
add a range to the heap
static char * ReAllocChar(char *vp, size_t size, size_t oldsize)
Reallocate (i.e.
R__EXTERN void * gMmallocDesc
static void * fgFreeHookData
void Info(const char *location, const char *msgfmt,...)
static Bool_t fgHasCustomNewDelete
static size_t GetMaxBlockSize()
R__EXTERN TVirtualMutex * gGlobalMutex
static Bool_t gMemStatistics
static void * GetFreeHookData()
return static free hook data
static FreeHookFun_t GetFreeHook()
static void EnableStatistics(int size=-1, int ix=-1)
Enable memory usage statistics gathering.
static Bool_t HasCustomNewDelete()
return the has custom delete flag
static void SetCustomNewDelete()
set the has custom delete flag
static Int_t gAllocatedTotal
static FreeHookFun_t fgFreeHook
static void SetReAllocHooks(ReAllocFun_t func1, ReAllocCFun_t func2)
Set a custom ReAlloc handlers.
bool(void *) FreeIfTMapFile_t
static void * Alloc(size_t size)
Allocate a block of memory, that later can be resized using TStorage::ReAlloc().
static Int_t gAllocated[kObjMaxSize]
static void SetFreeHook(FreeHookFun_t func, void *data)
Set a free handler.
static Bool_t IsOnHeap(void *p)
is object at p in the heap?
R__EXTERN FreeIfTMapFile_t * gFreeIfTMapFile
void *(* ReAllocCFun_t)(void *, size_t, size_t)
#define R__LOCKGUARD(mutex)
static Int_t gFreed[kObjMaxSize]
static void * ReAlloc(void *vp, size_t size)
Reallocate (i.e.
void(* FreeHookFun_t)(void *, void *addr, size_t)
static void RemoveStat(void *p)
Register a memory free operation.
Short_t Max(Short_t a, Short_t b)
static void SetMaxBlockSize(size_t size)
static Int_t gTraceCapacity
static void * ObjectAllocArray(size_t size)
Used to allocate array of TObject on the heap (via TObject::operator new[]()).
static void ** gTraceArray
static ReAllocFun_t fgReAllocHook
static size_t fgMaxBlockSize
static void ObjectDealloc(void *vp)
Used to deallocate a TObject on the heap (via TObject::operator delete()).
static void PrintStatistics()
Print memory usage statistics.
static Int_t * ReAllocInt(Int_t *vp, size_t size, size_t oldsize)
Reallocate (i.e.