TRef and possible memory leak

Hello all,

I’m looking for some advice.
I’m writing large trees containing event objects. These objects split up into several sub-objects (tracks, vertices etc.) which are in most cases organised in TClonesArrays. The sub-objects might be interlinked by TRef or TRefArrays.
Recently my program crashes after a while. The way how it crashes looks like a memory leak. Using the TObjectTable printing facility I see a steadily increasing number of TRef objects which I would not expect. The TRef objects are declared in the header of the parent class and defined when the parent class is filled. I do not use the new operator for TRef in any case, because they all have a fixed size. The TRef data members are set to 0 in the destructor and the Clear() function of the parent classes. So, why do the TRef objects reside in memory then? I’m using the same scheme for TVector3 and TLorentzVector objects and here it works perfect.
Any ideas would be greatly appreciated.
I’m using root version 4.00_08 on a linux machine with gcc2.95.3 installed.

Oliver

Hi Oliver,

May be you will find some inspiration reading the doc of TRef, inparticular the section “ObjectNumber” at
root.cern.ch/root/htmldoc/TRef.html

Rene

Dear René,

I forgot to mention that the ObjectNumber is already re-set inside my event loop already. Meanwhile I realised that the TRef objects do not necessarily have a fixed size (I was misleaded by the example in $ROOTSYS/test/Event.*). So I changed my code from simple assigments to explicit use of the new and delete operators. Now it seems to work. At least the TRef objects are removed from the heap after every event cycle.

With best regards,
Oliver