Hi Rooters, I write a program which reads events, extracts selected branches, and writes the truncated events back to another file. The program is more or less cloned from the copytree2.C example macro at http://root.cern.ch/root/html/examples/copytree2.C.html . It works, except that it acts as a memory hog, i.e. grows bigger and bigger during execution. The following is an excerpt, the full code is in the attachment. >>>>>>>>>>>> Int_t maxVirtualSize = 8000000; TROOT rootSys ( "GLAST", "GLAST Event" ); TFile* f = new TFile ( file, "read" ); TTree* T = (TTree*)f->Get("T"); T->SetMaxVirtualSize(maxVirtualSize); Event* event = new Event(); T->SetBranchAddress ( "Event", &event ); T->SetBranchStatus ( "*", 0 ); T->SetBranchStatus ( "m_event", 1 ); T->SetBranchStatus ( "m_TKR", 1 ); TFile* of = new TFile ( outFile, "recreate", "stripped test beam file" ); TTree* oT = T->CloneTree(0); oT->Reset(); oT->SetMaxVirtualSize(maxVirtualSize); oT->SetAutoSave(maxVirtualSize); oT->GetBranch("m_event")->SetFile(outFile); oT->GetBranch("m_TKR")->SetFile(outFile); gObjectTable->Print(); oT->CopyEntries( T, nEvent ); gObjectTable->Print(); of->Write(); delete of; delete f; <<<<<<<<<<<< I don't see the memory leak. The memory is being allocated during oT->CopyEntries(), and released on program termination. The gObjectTable->Print() statements enclosing oT->CopyEntries() give identical output before and after. >>>>>>>>>>>> Object statistics class cnt on heap size total size heap size ============================================================================ TObject 42 42 12 504 504 TOrdCollection 5 5 44 220 220 TEnv 1 1 24 24 24 THashTable 2 2 40 80 80 TClassTable 1 1 12 12 12 TObjectTable 1 1 24 24 24 TROOT 1 0 256 256 0 THashList 2 2 48 96 96 TUnixSystem 1 1 320 320 320 ---------------------------------------------------------------------------- Total: 56 55 780 1536 1280 ============================================================================ <<<<<<<<<<<< Looking into the TTree.cxx sources also didn't reveal something suspicious. I assumed that oT->SetMaxVirtualSize() is limiting the amount of memory used, but this does not seem to be the case. WHAT AM I MISSING? Thanks, Michael
This archive was generated by hypermail 2b29 : Fri Jun 08 2001 - 11:51:13 MEST