Dear Root-ers, Below are two macro's. The first one creates a root file with a directory and a tree and the second one reads it many times. This should simulate a 'real' application where several root files contain directories in which tree's have been created with the same name. My problem is that I can not figure out how to clean up after, getting the data from a file. The "delete dir;" is resulting in a segmentation violation. Removing this statement makes root use more and more memory. Is there a way to avoid this memory leak ? best regards, Eddy { gROOT->Reset(); Int_t split = 0; Int_t bsize = 32000; TFile *hfile = new TFile("foo.root","RECREATE"); TDirectory *dir = hfile->mkdir("dir"); dir->cd(); TTree *tree = new TTree( "T", "this is a tree" ); Int_t tmp = 100; TBranch *branch = tree->Branch("B",&tmp,"tmp/I",bsize); tree->Fill(); hfile->Write(); hfile->Close(); delete hfile; } { for (Int_t i=1; i >0; i++) { TFile *hfile = new TFile("foo.root","READ"); TDirectory *dir = (TDirectory *) hfile->Get("dir"); dir->cd(); TTree *tree = (TTree*) dir->Get("T"); Int_t tmp; tree->SetBranchAddress("B",&tmp); tree->GetEvent(0); printf("i tmp = %d %d\n",i,tmp); delete tree; delete dir; hfile->Close(); delete hfile; } }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:37 MET