Hi Pasha, Indeed, gObjectTable->Print() indicates that everything has been cleaned up . However, I am looking at the process root.exe with 'top'. It starts like: PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND 4524 eddy 1 33 0 18M 12M sleep 0:00 0.06% root.exe But after 1000 cycles in the 'read()' macro it is: 4524 eddy 1 -25 0 19M 14M sleep 0:09 2.18% root.exe Somehow, it has allocated an additional 1Mb. Best regards, Eddy Offermann ps. I am running Sun/Solaris for SPARC 2.00/11 > > > Eddy Offermann writes: > > Dear Root-ers, > > > > two questions: > > > > 1) two weeks ago, I had a question concerning cleanup of objects. > > The answer of Rene Brun seems only to solve part of the problem: > > the program does not crash anymore but we still have > > a memory leak. Below is a macro that makes a root file, followed > > by a macro that keeps on opening and closing it. > > Even when I comment out the "cd" and "tree" statements, the > > program size keeps growing. > > Maybe it is silly to be worried about an increase of 1Mb after about > > opening/closing 1000 files but if anybody could shed some light > > on this, I would appreciate it. > > > > make() > > { > > gROOT->Reset(); > > > > TFile *hfile = new TFile( "foo.root", "RECREATE" ); > > TDirectory *sub = hfile->mkdir("sub"); > > sub->cd(); > > TTree *tree = new TTree( "tree", "tree" ); > > > > Int_t tmp = 100; > > Int_t split = 1; > > Int_t bsize = 64000; > > TBranch *branch = tree->Branch("branch", &tmp, "", bsize); > > tree->Fill(); > > > > hfile->Write(); > > delete tree; > > hfile->Close(); > > delete hfile; > > } > > > > read() > > { > > for (Int_t i=1; i >0; i++) <---------- **** this never stops.... > > { > > printf("%d\n",i); > > > > TFile *hfile = new TFile("foo.root","READ"); > > hfile->cd("sub"); > > > > TTree *tree = (TTree*) gDirectory->Get("T"); <----- **** wrong, should be > TTree *tree = (TTree*) gDirectory->Get("tree"); > > delete tree; > > > > hfile->Close(); > > delete hfile; > > } > > } > > > > > I fixed `read()' in the example above : > -------------------------------------------------------------------------------- > read() { > for (Int_t i=1; i < 1000; i++) { > TFile *hfile = new TFile("foo.root","READ"); > TTree *tree = (TTree*) gDirectory->Get("/sub/tree"); // > delete tree; > delete hfile; > } > } > -------------------------------------------------------------------------------- > and ran it 1000 times. The output of gObjectTable->Print() says that it is > TKey objects which are not being deleted. The rest things are pretty > much under control (sorry, it is still ROOT 2.00/08). > > -regards, pasha. > -------------------------------------------------------------------------------- > root [0] gObjectTable->Print() > > Object statistics > class cnt on heap size total size heap size > ============================================================================ > TOrdCollection 5 5 40 200 200 > TList 33 33 40 1320 1320 > TGXW 1 1 84 84 84 > TFileHandler 2 2 20 40 40 > TSignalHandler 1 1 24 24 24 > TGX11 1 1 196 196 196 > TGaxis 1 0 132 132 0 > THashList 8 8 44 352 352 > TSystemDirectory 1 1 36 36 36 > TObject 38 38 12 456 456 > THashTable 8 8 36 288 288 > TRint 1 1 120 120 120 > TGClient 1 1 76 76 76 > TCint 1 1 208 208 208 > TPostScript 1 1 764 764 764 > TBenchmark 1 1 52 52 52 > TStyle 2 2 656 1312 1312 > TClass 19 19 64 1216 1216 > TROOT 1 0 240 240 0 > TGuiFactory 1 1 28 28 28 > TRootGuiFactory 1 1 28 28 28 > TGPicturePool 1 1 28 28 28 > TGMimeTypes 1 1 32 32 32 > TGeometry 1 1 64 64 64 > TGFrame 1 1 52 52 52 > TClassTable 1 1 12 12 12 > TObjectTable 1 1 24 24 24 > TStopwatch 1 0 56 56 0 > TEnv 1 1 24 24 24 > TRandom 1 1 32 32 32 > TAxis 3 0 100 300 0 > TUnixSystem 1 1 252 252 252 > ---------------------------------------------------------------------------- > Total: 141 135 3576 8048 7320 > ============================================================================ > > root [1] .L eddie.C > root [2] make() > root [2] read() > root [3] gObjectTable->Print() > > Object statistics > class cnt on heap size total size heap size > ============================================================================ > TOrdCollection 5 5 40 200 200 > TList 58 58 40 2320 2320 > TGXW 1 1 84 84 84 > TFileHandler 2 2 20 40 40 > TSignalHandler 1 1 24 24 24 > TGX11 1 1 196 196 196 > TGaxis 1 0 132 132 0 > THashList 8 8 44 352 352 > TSystemDirectory 1 1 36 36 36 > TObject 38 38 12 456 456 > THashTable 8 8 36 288 288 > TRint 1 1 120 120 120 > TGClient 1 1 76 76 76 > TCint 1 1 208 208 208 > TPostScript 1 1 764 764 764 > TBenchmark 1 1 52 52 52 > TStyle 2 2 656 1312 1312 > TClass 43 43 64 2752 2752 > TROOT 1 0 240 240 0 > TGuiFactory 1 1 28 28 28 > TRootGuiFactory 1 1 28 28 28 > TGPicturePool 1 1 28 28 28 > TGMimeTypes 1 1 32 32 32 > TGeometry 1 1 64 64 64 > TGFrame 1 1 52 52 52 > TClassTable 1 1 12 12 12 > TObjectTable 1 1 24 24 24 > TStopwatch 1 0 56 56 0 > TEnv 1 1 24 24 24 > TRandom 1 1 32 32 32 > TAxis 3 0 100 300 0 > TUnixSystem 1 1 252 252 252 > TKey 999 999 80 79920 79920 > TBaseClass 6 6 24 144 144 > ---------------------------------------------------------------------------- > Total: 1195 1189 3680 90648 89920 > ============================================================================ > > >
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:38 MET