// @(#)root/memstat:$Id$
// Author: Anar Manafov (A.Manafov@gsi.de) 2008-03-02

/*************************************************************************
* Copyright (C) 1995-2010, Rene Brun and Fons Rademakers.               *
* All rights reserved.                                                  *
*                                                                       *
* For the licensing terms see $ROOTSYS/LICENSE.                         *
* For the list of contributors see $ROOTSYS/README/CREDITS.             *
*************************************************************************/
// STD
#include <cstdlib>
// ROOT
#include "TSystem.h"
#include "TEnv.h"
#include "TError.h"
#include "Riostream.h"
#include "TObject.h"
#include "TFile.h"
#include "TTree.h"
#include "TArrayL64.h"
#include "TH1.h"
#include "TMD5.h"
#include "TMath.h"
// Memstat
#include "TMemStatBacktrace.h"
#include "TMemStatMng.h"

using namespace Memstat;

ClassImp(TMemStatMng)

TMemStatMng* TMemStatMng::fgInstance = NULL;

//****************************************************************************//
//
//****************************************************************************//

TMemStatMng::TMemStatMng():
   TObject(),
#if !defined(__APPLE__)
   fPreviousMallocHook(TMemStatHook::GetMallocHook()),
   fPreviousFreeHook(TMemStatHook::GetFreeHook()),
#endif
   fDumpFile(NULL),
   fDumpTree(NULL),
   fUseGNUBuiltinBacktrace(kFALSE),
   fBeginTime(0),
   fPos(0),
   fTimems(0),
   fNBytes(0),
   fBtID(0),
   fMaxCalls(5000000),
   fBufferSize(10000),
   fBufN(0),
   fBufPos(0),
   fBufTimems(0),
   fBufNBytes(0),
   fBufBtID(0),
   fIndex(0),
   fMustWrite(0),
   fFAddrsList(0),
   fHbtids(0),
   fBTCount(0),
   fBTIDCount(0),
   fSysInfo(0)
{
   // Default constructor
}

//______________________________________________________________________________
void TMemStatMng::Init()
{
   //Initialize MemStat manager - used only by instance method

   fBeginTime = fTimeStamp.AsDouble();

   fDumpFile = new TFile(Form("memstat_%d.root", gSystem->GetPid()), "recreate");
   Int_t opt = 200000;
   if(!fDumpTree) {
      fDumpTree = new TTree("T", "Memory Statistics");
      fDumpTree->Branch("pos",   &fPos,   "pos/l", opt);
      fDumpTree->Branch("time",  &fTimems, "time/I", opt);
      fDumpTree->Branch("nbytes", &fNBytes, "nbytes/I", opt);
      fDumpTree->Branch("btid",  &fBtID,  "btid/I", opt);
   }

   fBTCount = 0;

   fBTIDCount = 0;

   fFAddrsList = new TObjArray();
   fFAddrsList->SetOwner(kTRUE);
   fFAddrsList->SetName("FAddrsList");

   fHbtids  = new TH1I("btids", "table of btids", 10000, 0, 1);   //where fHbtids is a member of the manager class
   fHbtids->SetDirectory(0);
   // save the histogram and the TObjArray to the tree header
   fDumpTree->GetUserInfo()->Add(fHbtids);
   fDumpTree->GetUserInfo()->Add(fFAddrsList);
   // save the system info to a tree header
   std::string sSysInfo(gSystem->GetBuildNode());
   sSysInfo += " | ";
   sSysInfo += gSystem->GetBuildCompilerVersion();
   sSysInfo += " | ";
   sSysInfo += gSystem->GetFlagsDebug();
   sSysInfo += " ";
   sSysInfo += gSystem->GetFlagsOpt();
   fSysInfo = new TNamed("SysInfo", sSysInfo.c_str());

   fDumpTree->GetUserInfo()->Add(fSysInfo);
   fDumpTree->SetAutoSave(10000000);
}

//______________________________________________________________________________
TMemStatMng* TMemStatMng::GetInstance()
{
   // GetInstance - a static function
   // Initialize a singleton of MemStat manager

   if(!fgInstance) {
      fgInstance = new TMemStatMng;
      fgInstance->Init();
   }
   return fgInstance;
}

//______________________________________________________________________________
void TMemStatMng::Close()
{
   // Close - a static function
   // This method stops the manager,
   // flashes all the buffered data and closes the output tree.

   // TODO: This is a temporary solution until we find a properalgorithm for SaveData
   //fgInstance->fDumpFile->WriteObject(fgInstance->fFAddrsList, "FAddrsList");

/*  std::ofstream f("mem_stat_debug.txt");
  int *btids = fgInstance->fHbtids->GetArray();
   if( !btids )
      return;
   int btid(1);
   int count(0);
   bool bStop(false);
   int count_empty(0);
   for (int i = 0; i < fgInstance->fBTChecksums.size(); ++i)
   {
     if (bStop)
         break;
     count = btids[btid-1];
     f << "++++++++++++++++++++++++\n";
     f << "BTID: " << btid << "\n";
     if ( count <= 0 )
        ++count_empty;
     for (int j = btid+1; j <= (btid+count); ++j )
         {
           TNamed *nm = (TNamed*)fgInstance->fFAddrsList->At(btids[j]);
           if( !nm )
               {
                   f << "Bad ID" << std::endl;
                   bStop = true;
                }
           f << "-------> " << nm->GetTitle() << "\n";
         }
     btid = btid + count + 1;
   }
   f.close();
   ::Info("TMemStatMng::Close", "btids without a stack %d\n", count_empty);
*/

   // to be documented
   fgInstance->FillTree();
   fgInstance->Disable();
   fgInstance->fDumpTree->AutoSave();
   fgInstance->fDumpTree->GetUserInfo()->Delete();

   ::Info("TMemStatMng::Close", "Tree saved to file %s\n", fgInstance->fDumpFile->GetName());
   ::Info("TMemStatMng::Close", "Tree entries = %d, file size = %g MBytes\n", (Int_t)fgInstance->fDumpTree->GetEntries(),1e-6*Double_t(fgInstance->fDumpFile->GetEND()));

   delete fgInstance->fDumpFile;
   //fgInstance->fDumpFile->Close();
   //delete fgInstance->fFAddrsList;
   //delete fgInstance->fSysInfo;

   delete fgInstance;
   fgInstance = NULL;
}

//______________________________________________________________________________
TMemStatMng::~TMemStatMng()
{
   // if an instance is destructed - the hooks are reseted to old hooks

   if(this != TMemStatMng::GetInstance())
      return;

   Info("~TMemStatMng", ">>> All free/malloc calls count: %d", fBTIDCount);
   Info("~TMemStatMng", ">>> Unique BTIDs count: %zu", fBTChecksums.size());

   Disable();
}

//______________________________________________________________________________
void TMemStatMng::SetBufferSize(Int_t buffersize)
{
   // Set the maximum number of alloc/free calls to be buffered.
   //if the alloc and free are in the buffer, the corresponding entries
   //are not saved tio the Tree, reducing considerably the Tree output size

   fBufferSize = buffersize;
   if (fBufferSize < 1) fBufferSize = 1;
   fBufN = 0;
   fBufPos    = new ULong64_t[fBufferSize];
   fBufTimems = new Int_t[fBufferSize];
   fBufNBytes = new Int_t[fBufferSize];
   fBufBtID   = new Int_t[fBufferSize];
   fIndex     = new Int_t[fBufferSize];
   fMustWrite = new Bool_t[fBufferSize];
}

//______________________________________________________________________________
void TMemStatMng::SetMaxCalls(Int_t maxcalls)
{
   // Set the maximum number of new/delete registered in the output Tree.

   fMaxCalls = maxcalls;
}

//______________________________________________________________________________
void TMemStatMng::Enable()
{
   // Enable memory hooks

   if(this != GetInstance())
      return;
#if defined(__APPLE__)
   TMemStatHook::trackZoneMalloc(MacAllocHook, MacFreeHook);
#else
   // set hook to our functions
   TMemStatHook::SetMallocHook(AllocHook);
   TMemStatHook::SetFreeHook(FreeHook);
#endif
}

//______________________________________________________________________________
void TMemStatMng::Disable()
{
   // Disble memory hooks

   //FillTree();
   if(this != GetInstance())
      return;
#if defined(__APPLE__)
   TMemStatHook::untrackZoneMalloc();
#else
   // set hook to our functions
   TMemStatHook::SetMallocHook(fPreviousMallocHook);
   TMemStatHook::SetFreeHook(fPreviousFreeHook);
#endif
}

//______________________________________________________________________________
void TMemStatMng::MacAllocHook(void *ptr, size_t size)
{
   // AllocHook - a static function
   // a special memory hook for Mac OS X memory zones.
   // Triggered when memory is allocated.

   TMemStatMng* instance = TMemStatMng::GetInstance();
   // Restore all old hooks
   instance->Disable();

   // Call our routine
   instance->AddPointer(ptr, Int_t(size));

   // Restore our own hooks
   instance->Enable();
}

//______________________________________________________________________________
void TMemStatMng::MacFreeHook(void *ptr)
{
   // AllocHook - a static function
   // a special memory hook for Mac OS X memory zones.
   // Triggered when memory is deallocated.

   TMemStatMng* instance = TMemStatMng::GetInstance();
   // Restore all old hooks
   instance->Disable();

   // Call our routine
   instance->AddPointer(ptr, -1);

   // Restore our own hooks
   instance->Enable();
}

//______________________________________________________________________________
void *TMemStatMng::AllocHook(size_t size, const void* /*caller*/)
{
   // AllocHook - a static function
   // A glibc memory allocation hook.

   TMemStatMng* instance = TMemStatMng::GetInstance();
   // Restore all old hooks
   instance->Disable();

   // Call recursively
   void *result = malloc(size);
   // Call our routine
   instance->AddPointer(result, Int_t(size));
   //  TTimer::SingleShot(0, "TYamsMemMng", instance, "SaveData()");

   // Restore our own hooks
   instance->Enable();

   return result;
}

//______________________________________________________________________________
void TMemStatMng::FreeHook(void* ptr, const void* /*caller*/)
{
   // FreeHook - a static function
   // A glibc memory deallocation hook.

   TMemStatMng* instance = TMemStatMng::GetInstance();
   // Restore all old hooks
   instance->Disable();

   // Call recursively
   free(ptr);

   // Call our routine
   instance->AddPointer(ptr, -1);

   // Restore our own hooks
   instance->Enable();
}

//______________________________________________________________________________
Int_t TMemStatMng::generateBTID(UChar_t *CRCdigest, Int_t stackEntries,
                                void **stackPointers)
{
   // An internal function, which returns a bitid for a corresponding CRC digest
   // cache variables
   static Int_t old_btid = -1;
   static SCustomDigest old_digest;

   Int_t ret_val = -1;
   bool startCheck(false);
   if(old_btid >= 0) {
      for(int i = 0; i < g_digestSize; ++i) {
         if(old_digest.fValue[i] != CRCdigest[i]) {
            startCheck = true;
            break;
         }
      }
      ret_val = old_btid;
   } else {
      startCheck = true;
   }

   // return cached value
   if(!startCheck)
      return ret_val;

   old_digest = SCustomDigest(CRCdigest);
   CRCSet_t::const_iterator found = fBTChecksums.find(CRCdigest);

   if(fBTChecksums.end() == found) {
      // check the size of the BT array container
      const int nbins = fHbtids->GetNbinsX();
      //check that the current allocation in fHbtids is enough, otherwise expend it with
      if(fBTCount + stackEntries + 1 >= nbins) {
         fHbtids->SetBins(nbins * 2, 0, 1);
      }

      int *btids = fHbtids->GetArray();
      // the first value is a number of entries in a given stack
      btids[fBTCount++] = stackEntries;
      ret_val = fBTCount;
      if(stackEntries <= 0) {
         Warning("AddPointer",
                 "A number of stack entries is equal or less than zero. For btid %d", ret_val);
      }

      // add new BT's CRC value
      std::pair<CRCSet_t::iterator, bool> res = fBTChecksums.insert(CRCSet_t::value_type(CRCdigest, ret_val));
      if(!res.second)
         Error("AddPointer", "Can't added a new BTID to the container.");

      // save all symbols of this BT
      for(int i = 0; i < stackEntries; ++i) {
         ULong_t func_addr = (ULong_t)(stackPointers[i]);
         Int_t idx = fFAddrs.find(func_addr);
         // check, whether it's a new symbol
         if(idx < 0) {
            TString strFuncAddr;
            strFuncAddr += func_addr;
            TString strSymbolInfo;
            getSymbolFullInfo(stackPointers[i], &strSymbolInfo);

            TNamed *nm = new TNamed(strFuncAddr, strSymbolInfo);
            fFAddrsList->Add(nm);
            idx = fFAddrsList->GetEntriesFast() - 1;
            // TODO: more detailed error message...
            if(!fFAddrs.add(func_addr, idx))
               Error("AddPointer", "Can't add a function return address to the container");
         }

         // even if we have -1 as an index we add it to the container
         btids[fBTCount++] = idx;
      }

   } else {
      // reuse an existing BT
      ret_val = found->second;
   }

   old_btid = ret_val;

   return ret_val;
}

//______________________________________________________________________________
void TMemStatMng::AddPointer(void *ptr, Int_t size)
{
   // Add pointer to table.
   // This method is called every time when any of the hooks are triggered.
   // The memory de-/allocation information will is recorded.

   void *stptr[g_BTStackLevel + 1];
   const int stackentries = getBacktrace(stptr, g_BTStackLevel, fUseGNUBuiltinBacktrace);

   // save only unique BTs
   TMD5 md5;
   md5.Update(reinterpret_cast<UChar_t*>(stptr), sizeof(void*) * stackentries);
   UChar_t digest[g_digestSize];
   md5.Final(digest);

   // for Debug. A counter of all (de)allacations.
   ++fBTIDCount;

   Int_t btid(generateBTID(digest, stackentries, stptr));

   if(btid <= 0)
      Error("AddPointer", "bad BT id");

   fTimeStamp.Set();
   Double_t CurTime = fTimeStamp.AsDouble();
   fBufTimems[fBufN] = Int_t(10000.*(CurTime - fBeginTime));
   ULong_t ul = (ULong_t)(ptr);
   fBufPos[fBufN]    = (ULong64_t)(ul);
   fBufNBytes[fBufN] = size;
   fBufBtID[fBufN]   = btid;
   fBufN++;
   if (fBufN >= fBufferSize) {
      FillTree();
   }
}

//______________________________________________________________________________
void TMemStatMng::FillTree()
{
   //loop on all entries in the buffer and fill the output Tree
   //entries with alloc and free in the buffer are eliminated


   //eliminate alloc/free pointing to the same location in the current buffer
   TMath::Sort(fBufN,fBufPos,fIndex,kFALSE);
   memset(fMustWrite,0,fBufN*sizeof(Bool_t));
   Int_t i=0,j;
   while (i<fBufN) {
      Int_t indi = fIndex[i];
      Int_t indmin = indi;
      Int_t indmax = indi;
      j = i+1;;
      ULong64_t pos = fBufPos[indi];
      while (j < fBufN) {
         Int_t indj = fIndex[j];
         ULong64_t posj = fBufPos[indj];
         if (posj != pos) break;
         if (indmin > indj) indmin = indj;
         if (indmax < indj) indmax = indj;
         j++;
      }
      if (indmin == indmax) fMustWrite[indmin] = kTRUE;
      if (fBufNBytes[indmin] == -1) fMustWrite[indmin] = kTRUE;
      if (fBufNBytes[indmax] > 0)   fMustWrite[indmax] = kTRUE;
      i = j;
   }

   // now fill the Tree with the remaining allocs/frees
   for (i=0;i<fBufN;i++) {
      if (!fMustWrite[i]) continue;
      fPos    = fBufPos[i];
      fTimems = fBufTimems[i];
      fNBytes = fBufNBytes[i];
      fBtID   = fBufBtID[i];
      fDumpTree->Fill();
   }

   fBufN = 0;
   if (fDumpTree->GetEntries() >= fMaxCalls) TMemStatMng::GetInstance()->Disable();
}
 TMemStatMng.cxx:1
 TMemStatMng.cxx:2
 TMemStatMng.cxx:3
 TMemStatMng.cxx:4
 TMemStatMng.cxx:5
 TMemStatMng.cxx:6
 TMemStatMng.cxx:7
 TMemStatMng.cxx:8
 TMemStatMng.cxx:9
 TMemStatMng.cxx:10
 TMemStatMng.cxx:11
 TMemStatMng.cxx:12
 TMemStatMng.cxx:13
 TMemStatMng.cxx:14
 TMemStatMng.cxx:15
 TMemStatMng.cxx:16
 TMemStatMng.cxx:17
 TMemStatMng.cxx:18
 TMemStatMng.cxx:19
 TMemStatMng.cxx:20
 TMemStatMng.cxx:21
 TMemStatMng.cxx:22
 TMemStatMng.cxx:23
 TMemStatMng.cxx:24
 TMemStatMng.cxx:25
 TMemStatMng.cxx:26
 TMemStatMng.cxx:27
 TMemStatMng.cxx:28
 TMemStatMng.cxx:29
 TMemStatMng.cxx:30
 TMemStatMng.cxx:31
 TMemStatMng.cxx:32
 TMemStatMng.cxx:33
 TMemStatMng.cxx:34
 TMemStatMng.cxx:35
 TMemStatMng.cxx:36
 TMemStatMng.cxx:37
 TMemStatMng.cxx:38
 TMemStatMng.cxx:39
 TMemStatMng.cxx:40
 TMemStatMng.cxx:41
 TMemStatMng.cxx:42
 TMemStatMng.cxx:43
 TMemStatMng.cxx:44
 TMemStatMng.cxx:45
 TMemStatMng.cxx:46
 TMemStatMng.cxx:47
 TMemStatMng.cxx:48
 TMemStatMng.cxx:49
 TMemStatMng.cxx:50
 TMemStatMng.cxx:51
 TMemStatMng.cxx:52
 TMemStatMng.cxx:53
 TMemStatMng.cxx:54
 TMemStatMng.cxx:55
 TMemStatMng.cxx:56
 TMemStatMng.cxx:57
 TMemStatMng.cxx:58
 TMemStatMng.cxx:59
 TMemStatMng.cxx:60
 TMemStatMng.cxx:61
 TMemStatMng.cxx:62
 TMemStatMng.cxx:63
 TMemStatMng.cxx:64
 TMemStatMng.cxx:65
 TMemStatMng.cxx:66
 TMemStatMng.cxx:67
 TMemStatMng.cxx:68
 TMemStatMng.cxx:69
 TMemStatMng.cxx:70
 TMemStatMng.cxx:71
 TMemStatMng.cxx:72
 TMemStatMng.cxx:73
 TMemStatMng.cxx:74
 TMemStatMng.cxx:75
 TMemStatMng.cxx:76
 TMemStatMng.cxx:77
 TMemStatMng.cxx:78
 TMemStatMng.cxx:79
 TMemStatMng.cxx:80
 TMemStatMng.cxx:81
 TMemStatMng.cxx:82
 TMemStatMng.cxx:83
 TMemStatMng.cxx:84
 TMemStatMng.cxx:85
 TMemStatMng.cxx:86
 TMemStatMng.cxx:87
 TMemStatMng.cxx:88
 TMemStatMng.cxx:89
 TMemStatMng.cxx:90
 TMemStatMng.cxx:91
 TMemStatMng.cxx:92
 TMemStatMng.cxx:93
 TMemStatMng.cxx:94
 TMemStatMng.cxx:95
 TMemStatMng.cxx:96
 TMemStatMng.cxx:97
 TMemStatMng.cxx:98
 TMemStatMng.cxx:99
 TMemStatMng.cxx:100
 TMemStatMng.cxx:101
 TMemStatMng.cxx:102
 TMemStatMng.cxx:103
 TMemStatMng.cxx:104
 TMemStatMng.cxx:105
 TMemStatMng.cxx:106
 TMemStatMng.cxx:107
 TMemStatMng.cxx:108
 TMemStatMng.cxx:109
 TMemStatMng.cxx:110
 TMemStatMng.cxx:111
 TMemStatMng.cxx:112
 TMemStatMng.cxx:113
 TMemStatMng.cxx:114
 TMemStatMng.cxx:115
 TMemStatMng.cxx:116
 TMemStatMng.cxx:117
 TMemStatMng.cxx:118
 TMemStatMng.cxx:119
 TMemStatMng.cxx:120
 TMemStatMng.cxx:121
 TMemStatMng.cxx:122
 TMemStatMng.cxx:123
 TMemStatMng.cxx:124
 TMemStatMng.cxx:125
 TMemStatMng.cxx:126
 TMemStatMng.cxx:127
 TMemStatMng.cxx:128
 TMemStatMng.cxx:129
 TMemStatMng.cxx:130
 TMemStatMng.cxx:131
 TMemStatMng.cxx:132
 TMemStatMng.cxx:133
 TMemStatMng.cxx:134
 TMemStatMng.cxx:135
 TMemStatMng.cxx:136
 TMemStatMng.cxx:137
 TMemStatMng.cxx:138
 TMemStatMng.cxx:139
 TMemStatMng.cxx:140
 TMemStatMng.cxx:141
 TMemStatMng.cxx:142
 TMemStatMng.cxx:143
 TMemStatMng.cxx:144
 TMemStatMng.cxx:145
 TMemStatMng.cxx:146
 TMemStatMng.cxx:147
 TMemStatMng.cxx:148
 TMemStatMng.cxx:149
 TMemStatMng.cxx:150
 TMemStatMng.cxx:151
 TMemStatMng.cxx:152
 TMemStatMng.cxx:153
 TMemStatMng.cxx:154
 TMemStatMng.cxx:155
 TMemStatMng.cxx:156
 TMemStatMng.cxx:157
 TMemStatMng.cxx:158
 TMemStatMng.cxx:159
 TMemStatMng.cxx:160
 TMemStatMng.cxx:161
 TMemStatMng.cxx:162
 TMemStatMng.cxx:163
 TMemStatMng.cxx:164
 TMemStatMng.cxx:165
 TMemStatMng.cxx:166
 TMemStatMng.cxx:167
 TMemStatMng.cxx:168
 TMemStatMng.cxx:169
 TMemStatMng.cxx:170
 TMemStatMng.cxx:171
 TMemStatMng.cxx:172
 TMemStatMng.cxx:173
 TMemStatMng.cxx:174
 TMemStatMng.cxx:175
 TMemStatMng.cxx:176
 TMemStatMng.cxx:177
 TMemStatMng.cxx:178
 TMemStatMng.cxx:179
 TMemStatMng.cxx:180
 TMemStatMng.cxx:181
 TMemStatMng.cxx:182
 TMemStatMng.cxx:183
 TMemStatMng.cxx:184
 TMemStatMng.cxx:185
 TMemStatMng.cxx:186
 TMemStatMng.cxx:187
 TMemStatMng.cxx:188
 TMemStatMng.cxx:189
 TMemStatMng.cxx:190
 TMemStatMng.cxx:191
 TMemStatMng.cxx:192
 TMemStatMng.cxx:193
 TMemStatMng.cxx:194
 TMemStatMng.cxx:195
 TMemStatMng.cxx:196
 TMemStatMng.cxx:197
 TMemStatMng.cxx:198
 TMemStatMng.cxx:199
 TMemStatMng.cxx:200
 TMemStatMng.cxx:201
 TMemStatMng.cxx:202
 TMemStatMng.cxx:203
 TMemStatMng.cxx:204
 TMemStatMng.cxx:205
 TMemStatMng.cxx:206
 TMemStatMng.cxx:207
 TMemStatMng.cxx:208
 TMemStatMng.cxx:209
 TMemStatMng.cxx:210
 TMemStatMng.cxx:211
 TMemStatMng.cxx:212
 TMemStatMng.cxx:213
 TMemStatMng.cxx:214
 TMemStatMng.cxx:215
 TMemStatMng.cxx:216
 TMemStatMng.cxx:217
 TMemStatMng.cxx:218
 TMemStatMng.cxx:219
 TMemStatMng.cxx:220
 TMemStatMng.cxx:221
 TMemStatMng.cxx:222
 TMemStatMng.cxx:223
 TMemStatMng.cxx:224
 TMemStatMng.cxx:225
 TMemStatMng.cxx:226
 TMemStatMng.cxx:227
 TMemStatMng.cxx:228
 TMemStatMng.cxx:229
 TMemStatMng.cxx:230
 TMemStatMng.cxx:231
 TMemStatMng.cxx:232
 TMemStatMng.cxx:233
 TMemStatMng.cxx:234
 TMemStatMng.cxx:235
 TMemStatMng.cxx:236
 TMemStatMng.cxx:237
 TMemStatMng.cxx:238
 TMemStatMng.cxx:239
 TMemStatMng.cxx:240
 TMemStatMng.cxx:241
 TMemStatMng.cxx:242
 TMemStatMng.cxx:243
 TMemStatMng.cxx:244
 TMemStatMng.cxx:245
 TMemStatMng.cxx:246
 TMemStatMng.cxx:247
 TMemStatMng.cxx:248
 TMemStatMng.cxx:249
 TMemStatMng.cxx:250
 TMemStatMng.cxx:251
 TMemStatMng.cxx:252
 TMemStatMng.cxx:253
 TMemStatMng.cxx:254
 TMemStatMng.cxx:255
 TMemStatMng.cxx:256
 TMemStatMng.cxx:257
 TMemStatMng.cxx:258
 TMemStatMng.cxx:259
 TMemStatMng.cxx:260
 TMemStatMng.cxx:261
 TMemStatMng.cxx:262
 TMemStatMng.cxx:263
 TMemStatMng.cxx:264
 TMemStatMng.cxx:265
 TMemStatMng.cxx:266
 TMemStatMng.cxx:267
 TMemStatMng.cxx:268
 TMemStatMng.cxx:269
 TMemStatMng.cxx:270
 TMemStatMng.cxx:271
 TMemStatMng.cxx:272
 TMemStatMng.cxx:273
 TMemStatMng.cxx:274
 TMemStatMng.cxx:275
 TMemStatMng.cxx:276
 TMemStatMng.cxx:277
 TMemStatMng.cxx:278
 TMemStatMng.cxx:279
 TMemStatMng.cxx:280
 TMemStatMng.cxx:281
 TMemStatMng.cxx:282
 TMemStatMng.cxx:283
 TMemStatMng.cxx:284
 TMemStatMng.cxx:285
 TMemStatMng.cxx:286
 TMemStatMng.cxx:287
 TMemStatMng.cxx:288
 TMemStatMng.cxx:289
 TMemStatMng.cxx:290
 TMemStatMng.cxx:291
 TMemStatMng.cxx:292
 TMemStatMng.cxx:293
 TMemStatMng.cxx:294
 TMemStatMng.cxx:295
 TMemStatMng.cxx:296
 TMemStatMng.cxx:297
 TMemStatMng.cxx:298
 TMemStatMng.cxx:299
 TMemStatMng.cxx:300
 TMemStatMng.cxx:301
 TMemStatMng.cxx:302
 TMemStatMng.cxx:303
 TMemStatMng.cxx:304
 TMemStatMng.cxx:305
 TMemStatMng.cxx:306
 TMemStatMng.cxx:307
 TMemStatMng.cxx:308
 TMemStatMng.cxx:309
 TMemStatMng.cxx:310
 TMemStatMng.cxx:311
 TMemStatMng.cxx:312
 TMemStatMng.cxx:313
 TMemStatMng.cxx:314
 TMemStatMng.cxx:315
 TMemStatMng.cxx:316
 TMemStatMng.cxx:317
 TMemStatMng.cxx:318
 TMemStatMng.cxx:319
 TMemStatMng.cxx:320
 TMemStatMng.cxx:321
 TMemStatMng.cxx:322
 TMemStatMng.cxx:323
 TMemStatMng.cxx:324
 TMemStatMng.cxx:325
 TMemStatMng.cxx:326
 TMemStatMng.cxx:327
 TMemStatMng.cxx:328
 TMemStatMng.cxx:329
 TMemStatMng.cxx:330
 TMemStatMng.cxx:331
 TMemStatMng.cxx:332
 TMemStatMng.cxx:333
 TMemStatMng.cxx:334
 TMemStatMng.cxx:335
 TMemStatMng.cxx:336
 TMemStatMng.cxx:337
 TMemStatMng.cxx:338
 TMemStatMng.cxx:339
 TMemStatMng.cxx:340
 TMemStatMng.cxx:341
 TMemStatMng.cxx:342
 TMemStatMng.cxx:343
 TMemStatMng.cxx:344
 TMemStatMng.cxx:345
 TMemStatMng.cxx:346
 TMemStatMng.cxx:347
 TMemStatMng.cxx:348
 TMemStatMng.cxx:349
 TMemStatMng.cxx:350
 TMemStatMng.cxx:351
 TMemStatMng.cxx:352
 TMemStatMng.cxx:353
 TMemStatMng.cxx:354
 TMemStatMng.cxx:355
 TMemStatMng.cxx:356
 TMemStatMng.cxx:357
 TMemStatMng.cxx:358
 TMemStatMng.cxx:359
 TMemStatMng.cxx:360
 TMemStatMng.cxx:361
 TMemStatMng.cxx:362
 TMemStatMng.cxx:363
 TMemStatMng.cxx:364
 TMemStatMng.cxx:365
 TMemStatMng.cxx:366
 TMemStatMng.cxx:367
 TMemStatMng.cxx:368
 TMemStatMng.cxx:369
 TMemStatMng.cxx:370
 TMemStatMng.cxx:371
 TMemStatMng.cxx:372
 TMemStatMng.cxx:373
 TMemStatMng.cxx:374
 TMemStatMng.cxx:375
 TMemStatMng.cxx:376
 TMemStatMng.cxx:377
 TMemStatMng.cxx:378
 TMemStatMng.cxx:379
 TMemStatMng.cxx:380
 TMemStatMng.cxx:381
 TMemStatMng.cxx:382
 TMemStatMng.cxx:383
 TMemStatMng.cxx:384
 TMemStatMng.cxx:385
 TMemStatMng.cxx:386
 TMemStatMng.cxx:387
 TMemStatMng.cxx:388
 TMemStatMng.cxx:389
 TMemStatMng.cxx:390
 TMemStatMng.cxx:391
 TMemStatMng.cxx:392
 TMemStatMng.cxx:393
 TMemStatMng.cxx:394
 TMemStatMng.cxx:395
 TMemStatMng.cxx:396
 TMemStatMng.cxx:397
 TMemStatMng.cxx:398
 TMemStatMng.cxx:399
 TMemStatMng.cxx:400
 TMemStatMng.cxx:401
 TMemStatMng.cxx:402
 TMemStatMng.cxx:403
 TMemStatMng.cxx:404
 TMemStatMng.cxx:405
 TMemStatMng.cxx:406
 TMemStatMng.cxx:407
 TMemStatMng.cxx:408
 TMemStatMng.cxx:409
 TMemStatMng.cxx:410
 TMemStatMng.cxx:411
 TMemStatMng.cxx:412
 TMemStatMng.cxx:413
 TMemStatMng.cxx:414
 TMemStatMng.cxx:415
 TMemStatMng.cxx:416
 TMemStatMng.cxx:417
 TMemStatMng.cxx:418
 TMemStatMng.cxx:419
 TMemStatMng.cxx:420
 TMemStatMng.cxx:421
 TMemStatMng.cxx:422
 TMemStatMng.cxx:423
 TMemStatMng.cxx:424
 TMemStatMng.cxx:425
 TMemStatMng.cxx:426
 TMemStatMng.cxx:427
 TMemStatMng.cxx:428
 TMemStatMng.cxx:429
 TMemStatMng.cxx:430
 TMemStatMng.cxx:431
 TMemStatMng.cxx:432
 TMemStatMng.cxx:433
 TMemStatMng.cxx:434
 TMemStatMng.cxx:435
 TMemStatMng.cxx:436
 TMemStatMng.cxx:437
 TMemStatMng.cxx:438
 TMemStatMng.cxx:439
 TMemStatMng.cxx:440
 TMemStatMng.cxx:441
 TMemStatMng.cxx:442
 TMemStatMng.cxx:443
 TMemStatMng.cxx:444
 TMemStatMng.cxx:445
 TMemStatMng.cxx:446
 TMemStatMng.cxx:447
 TMemStatMng.cxx:448
 TMemStatMng.cxx:449
 TMemStatMng.cxx:450
 TMemStatMng.cxx:451
 TMemStatMng.cxx:452
 TMemStatMng.cxx:453
 TMemStatMng.cxx:454
 TMemStatMng.cxx:455
 TMemStatMng.cxx:456
 TMemStatMng.cxx:457
 TMemStatMng.cxx:458
 TMemStatMng.cxx:459
 TMemStatMng.cxx:460
 TMemStatMng.cxx:461
 TMemStatMng.cxx:462
 TMemStatMng.cxx:463
 TMemStatMng.cxx:464
 TMemStatMng.cxx:465
 TMemStatMng.cxx:466
 TMemStatMng.cxx:467
 TMemStatMng.cxx:468
 TMemStatMng.cxx:469
 TMemStatMng.cxx:470
 TMemStatMng.cxx:471
 TMemStatMng.cxx:472
 TMemStatMng.cxx:473
 TMemStatMng.cxx:474
 TMemStatMng.cxx:475
 TMemStatMng.cxx:476
 TMemStatMng.cxx:477
 TMemStatMng.cxx:478
 TMemStatMng.cxx:479
 TMemStatMng.cxx:480
 TMemStatMng.cxx:481
 TMemStatMng.cxx:482
 TMemStatMng.cxx:483
 TMemStatMng.cxx:484
 TMemStatMng.cxx:485
 TMemStatMng.cxx:486
 TMemStatMng.cxx:487
 TMemStatMng.cxx:488
 TMemStatMng.cxx:489
 TMemStatMng.cxx:490
 TMemStatMng.cxx:491
 TMemStatMng.cxx:492
 TMemStatMng.cxx:493
 TMemStatMng.cxx:494
 TMemStatMng.cxx:495
 TMemStatMng.cxx:496
 TMemStatMng.cxx:497
 TMemStatMng.cxx:498
 TMemStatMng.cxx:499
 TMemStatMng.cxx:500
 TMemStatMng.cxx:501
 TMemStatMng.cxx:502
 TMemStatMng.cxx:503
 TMemStatMng.cxx:504
 TMemStatMng.cxx:505