Re: Is the memory leak in TTree->GetEvent(entry)?

From: Rene Brun <brun_at_pcroot.cern.ch>
Date: Fri, 15 Apr 2005 14:59:59 +0200 (MEST)


Hi,

To give a precise answer, we will need your Burst.h file and other relevant header files. We also need to see your Burst::Clear function. It looks like you may have some object collections in Burst that you do not delete.

Also, when reading, you can replace
 Burst *burst = new Burst();
by
 Burst *burst = 0;

Rene Brun

On
Fri, 15 Apr 2005 ywl_at_hep.pku.edu.cn wrote:

> Dear rooters,
>
> When I performed data analysis,I created a class(named Burst) to store
> the data in root files using the following style:
>
> "f = new TFile("test.root",RECREATE);
> t = new TTree("t","A Tree with Bursts");
> burst = new Burst();
> t->Branch("uDST","Burst",&burst,160000,2);"
>
> There is no problem in the process of storing,but when I used the stored
> data to analysis I met the trouble,the process of opening the files:
>
> "TFile *fin = new TFile("test.root");
> TTree *T = (TTree*)fin->Get("t");
> Burst *burst = new Burst();
> TBranch *TESTuDST = T->GetBranch("uDST");
> TESTuDST->SetAddress(&burst);
> Int_t TotBursts = T->GetEntries();
> for(Int_t i=0;i<TotBursts;i++){
> T->GetEvent(i); ...................(memory leak)
> ..............
> ..............
> burst->Clear();
> }
> delete burst;
> delete T;
> fin->Close();"
>
> I found there is very big memory oocupied when using the operation
> T->GetEvent(i) in the loop which did not be cleared at the end of the
> loop. I didn't find the suitable member function in class TTree to deal
> with this problem. As I want to analysize more than one files every time,
> the programme always breaked because of the memory exhausted.
> Could you like to help me solve this problem?
>
> Best regards,
> Weilin
>
Received on Fri Apr 15 2005 - 15:00:11 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:07 MET