Hi Rene,
I have a somewhat related question: I'd like to delete
all histograms IN MEMORY in the working directory. Do I
achieve that with:
delete gDirectory()->GetList();
or am I causing some collateral damage???
Note that I do NOT want to delete histograms
and ntuples that are written on the file.
Rene Brun wrote:
>
> Hi Simon,
>
> In general, Use the form
> delete inheritedclass;
>
> If your class is a ROOT collection, like TList, TObjArray, you can do:
> mycollection->Delete(); //to delete all objects in the collection;
> delete mycollection; // to delete the empty collection.
>
> Note that if the collection has been declared to be the owner with
> mycollection->SetOwner();
> it is sufficient to do:
> delete mycollection; //all owned objects will be automatically deleted.
>
> See also the chapter on Object Ownership in the Users Guide.
>
> Rene Brun
>
> Simon Dean wrote:
> >
> > Hi there,
> >
> > Could someone please explain to me the subtle nuances of destructors in
> > classes which inherit from TObject? I'm having problems with crashes
> > caused by such destructors, although I think the problem may be due to
> > delete statements inside them which refer to other classes that inherit
> > from TObject.
> >
> > What is TObject->Delete() and what is it used for? Would I do:
> >
> > delete inheritedclass
> > or
> > inheritedclass->Delete()
> >
> > for cleaning up memory.
> >
> > cheers,
> >
> > Simon
--
========================================================================
Vuko Brigljevic | Mail : SLAC, Mail Stop 41
Lawrence Livermore National Laboratory | P.O. Box 4349, Stanford
Nuclear and Particle Physics Division | CA 94309, USA
| SLAC-Office : B280- room 143
Member of the BaBar Collaboration | Phone : +1-650-926 8512
<vuko@slac.stanford.edu> <http://www.slac.stanford.edu/~vuko>
========================================================================
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:47 MET