Re: [ROOT] object ownership and memory management

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Sat Dec 30 2000 - 00:07:30 MET


Hi Dave,

   the kNotDeleted bit is a bit opportunistic. It is always set for
a valid object, and is likely, but not guaranteed, to not be set for
a just deleted object. The TObject dtor unsets this bit and if the 
TObject::fBits word is not reused between the calling of the dtor and
the checking of the bit it is ok. At best if gives a hint that the object
has been deleted.


Cheers, Fons.


On Fri, Dec 29, 2000 at 12:45:18PM -0800, Dave Casper wrote:
> 
> 	Hi,
> 
> I am trying to understand what facilities are provided for object ownership
> and memory management issues and clean up my own program to make it more
> robust.
> 
> Root seems to have a variety of facilities for avoiding memory leakage, but
> there is no global documentation that I have found.  There are a lot of
> things going on behind the scenes with TStorage and libNew.  On Windows, I
> have not been linking with libNew, since (some time ago) I found that it
> caused problems.  In addition, I am calling my class library from Geant4,
> and I'm not sure it is wise to impose a foreign, global operator new/delete
> on that package.
> 
> TObject has a bit kNotDeleted; I'm not clear on how this will work without
> libNew.  If one deletes something using a vanilla operator new, one is not
> supposed to assume the memory in question is valid afterward.  Supposing one
> deletes a TObject with the vanilla operator delete() (i.e. in the absence of
> libNew), how can one use the kNotDeleted bit which is part of the memory
> block you just deleted to check whether that block has, in fact, been
> deleted?  kNotDeleted doesn't seem to be really documented anywhere, so many
> I am misunderstanding its intent.
> 
> It would be good, I think, to eventually add a chapter on stuff like this to
> the Root manual.
> 
> Dave
> dcasper@uci.edu

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:40 MET