Re: Tree Questions

From: Valery Fine (fine@bnl.gov)
Date: Sat Jan 16 1999 - 05:08:54 MET


On 15 Jan 99 at 19:04, Christoph Borgmeier wrote:

> class A: public TObject
> {
> public:
>   A();
>   ~A();

>   A* f;
>   ClassDef(A,1)
> };

> I attach such an object to a branch and do something like a->f=new A (and
> maybe a->f->f=new A) and write it to a file. When I read these chains of
> objects back, everything is correctly restored, but a cout statement in
> the constructors and destructors shows me, that not all objects are
> deleted:

> Have I overlooked something or do I have to be more precise? Is there a
> way to look up these objects? The gObjectTable does not seem to contain
> them.

  Hmm, TTree/TBranch class call dtor of your "a" object only and leaves the
rest for the dtor of that object. It seems to me there is nothing special here.

  It is responsibility of your class to take care about nested data-members.
Apparently TTree has no idea how to "clean" internal data-members. Only dtor
(namely the author of the class) of the particular class knows this and 
nothing can (should) help here.

  The stack you presented shows there is a "well known" bug in your 
class dtor. It is named "memory leak". This leak is originated by your class 
dtor, sorry.

  Hope this helps,
                                 Valery
=================================================================
Dr. Valeri Faine (Fine)
    -------------------          Phone: +1 516 344 7806
Brookhaven National Laboratory   FAX  : +1 516 344 4206
Bldg. 510A /STAR                 mailto:fine@bnl.gov
Upton, New York, 11973-5000      http://nicewww.cern.ch/~fine
USA
                                 
Dr. Valery Fine                  Telex : 911621 dubna su
    -----------
LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80
141980 Dubna, Moscow region      Fax   : +7 09621 6 51 45
Russia                           mailto:fine@main1.jinr.dubna.su                              



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:28 MET