Rene Brun
Axel Schwank wrote:
>
> Dear ROOTers,
> I am looking for a way to trace the memory usage of my ROOT based program.
> It basically uses our own Event structure (class TH1Event) and a ROOT Tree
> consisting of a few brances that are built from data banks.
> The memory usage of this program becomes rather big (top or ps say 58 Mb
> approx.). Therefore I want to know where this memory goes.
> The executable is (with debugging information) 900 kb, the shared library
> for the local bank structures / Event Class 4.5 Mb, and the used ROOT
> libraries don't sum up to more than 6-8 Mb, I guess.
> I enriched the program's main loop with some statement that dump some
> memory information:
> gObjectTable->Print() gives the list of objects, the total sum of sizes
> grows only very slightly during execution and remains at approx. 260 kb.
> For more information about the real memory usage I wanted to use
> TStorage::PrintStatistics(), but it generates no output.
> Memory checking should be enabled normally, I nevertheless stated
> TStorage::EnableStatistics(), still the Print function keeps quiet.
> How can I learn more about who swallows my memory ?
> I use the new ROOT v2.0 (congratulations!) under IRIX 6.2
>
> Thanks, Axel
>
> ********************************
>
> Axel Schwank
>
> DESY H1-F22
> Notkestrasse 85
> D-22607 Hamburg
>
> Rm. 1b/269
> Tel (+49 40) 8998-3560
> Fax (+49 40) 8998-4385
>
> e-mail schwank@mail.desy.de
> Quix 0165-6-2705109
>
> ********************************
>
> ---------------------------------------------------------------
> #include <stdlib.h>
> #include <iostream.h>
>
> // ROOT classes
> #include <TROOT.h>
> #include <TFile.h>
> #include <TTree.h>
> #include <TBranch.h>
> #include <TStorage.h>
> #include <TObjectTable.h>
> #include <TEnv.h>
>
> // H1 classes
> #include "TH1Event.h"
> #include "TOutput.h"
>
> #include "minicf.h"
>
> // BOS
> #include "cxx_bos.h"
> #include "cxx_mdb.h"
> #include "cxx_fpack.h"
> #include "c_bcs.h"
> #include "c_bosmdl.h"
>
> Int_t cosmic(TH1Event*);
>
> TH1Event* gEvent;
> TOutput* gOutput;
> TObjectTable* gObjectTable;
>
> TROOT Cosmic("cosmic","Selection of events with cosmics");
>
> int main(int argc, char **argv){
>
> gROOT->SetBatch(kTRUE);
> gROOT->SetStyle("Plain");
>
> //------Set the rootfilename and number of events to process
>
> const TString rootfilepath = TString("/h1wgs/curacao/x01/usr/schwank/root/");
> TString rootfilename = TString("Event.root");
> Int_t Nevents = 1000000;
> if (argc>1) rootfilename = argv[1];
> if (argc>2) Nevents = atoi(argv[2]);
> TString rootfile = rootfilepath + rootfilename;
>
> Int_t eventno=0;
>
> //-----Init BOS
>
> const int nbnam=2000;
> int iret = 0,ierr = 0;
> c_bnames(nbnam);
> c_bos(Bcs.iw,NBOSIW);
> c_fparmr(5);
> c_breadc();
>
> //-----Init H1Event structure
>
> gEnv->Print();
> TStorage::EnableStatistics();
> gEvent = new TH1Event(1);
> gOutput= new TOutput(1);
> init_special_messages(gOutput);
>
> //-----open output file
>
> TFile *hfile = new TFile(rootfile,"RECREATE","Cosmic data");
> hfile->SetCompressionLevel(3);
> TTree *tree = new TTree("T","Required banks for cosmic analysis",2000000);
> tree->SetAutoSave(20000000); // autosave when 20 Mbyte written
> Int_t bufsize = 640;
> Int_t split = 1;
>
> //-----Create the branches, each required bank builds one branch
>
> tree->Branch("DTRA",&gEvent->fDtra,bufsize,split);
> tree->Branch("DTNV",&gEvent->fDtnv,bufsize,split);
> tree->Branch("DCOS",&gEvent->fDcos,bufsize,split);
> tree->Branch("DMUO",&gEvent->fDmuo,bufsize,split);
> tree->Branch("DTIO",&gEvent->fDtio,bufsize,split);
> tree->Branch("DVER",&gEvent->fDver,bufsize,split);
> tree->Branch("DMIS",&gEvent->fDmis,bufsize,split);
>
> // gObjectTable->Print();
> TStorage::PrintStatistics();
>
> //-----Main loop
>
> while (eventno<Nevents){
>
> c_fseqr("BOSINPUT",&iret);
> if(iret < 0) break;
>
> gEvent->FillDtra();
> gEvent->FillDtnv();
> gEvent->FillDcos();
> gEvent->FillDmuo();
> gEvent->FillDtio();
> gEvent->FillDver();
> gEvent->FillDmis();
>
> if (cosmic(gEvent)<1) {gEvent->Clear(); continue;}
> ++eventno;
> cout << "Event Number " << eventno << " : Run= "
> << Bosmdl.nccrun << " Event= " << Bosmdl.nevent <<endl;
>
> if (eventno%10==0) {
> gObjectTable->Print();
> TStorage::PrintStatistics();
> }
>
> //---Fill required banks in the tree
>
> tree->Fill();
> // c_fpcurx("BOSINPUT","IDXCRE",&ierr);
> gEvent->Clear();
> }
>
> hfile->Write();
>
> //-----close files
>
> hfile->Close();
> c_fparm("CLOSE ALL");
>
> return 0;
> }