Re: [ROOT] object deletion

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jun 18 2003 - 23:21:21 MEST


Hi Thomas,

I forgot to comment on your TObjArray in one of my previous mails.
Instead of creating/deleting this array for each event, I suggest
 -to declare a member in your TSelector derived class to point
   to this array. 
 -Create the array ONCE in the BEGIN function.
 -Delete the array in Terminate.

In ProcessCut, start with
   m_AnaJet_Particles->Delete();

This will be more efficient and will avoid the problem you are referring 
to.

Rene Brun

On Wed, 
18 Jun 2003, Thomas Schoerner wrote:

> Hello,
> 
> a probably very simple question:
> 
> Assume that in ProcessCut I create objects on the heap and have a cut
> which is not always fulfilled:
> 
> Bool_t AnaJet::ProcessCut(Int_t entry)
> {
>   m_AnaJet_Particles_Lab = new TObjArray;
> ...
> ...
>   if(somecondition) return kFALSE;
> ...
> ...
>   return kTRUE;
> }
> 
> If I manage to get to ProcessFill, I can delete the object and have no
> problem:
> 
> void AnaJet::ProcessFill(Int_t entry)
> {
> ...
>   delete m_AnaJet_Particles_Lab;
> ...
> }
> 
> BUt what if somecondition is not fulfilled and I do not get to
> ProcessFill? How can I efficienctly delete the object so that only the
> pointer remains and I can reallocate memory during the next event?
> 
> Cheers,
> 
> Thomas
> 
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET