Re: root I/O: economizing on objects?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jan 18 1999 - 12:36:59 MET


Richard Dubois wrote:
> 
>  I have a TObjArray of tracker hits. These hits contain a hit ID object.
> At this stage of the game, our hit ID's are not (yet) unique to all
> hits.
> 
>  I had set things up so that the tracker hit contained a pointer to the
> hit ID object and outfitted its (tracker hit) destructor with a delete
> of the hit ID. When I deleted the event, I got a crash which I traced to
> trying to delete a hit ID that was not there.
> 
>  I traced the code that created the root file; all pointers to the hit
> ID's were unique, however when tracing the destructor, the pointers in
> the root file started repeating themselves. Hence the crash when it
> tried to delete an ID that had already been deleted.
> 
>  I am guessing that, to conserve space(?), root I/O noticed these
> identical objects and got rid of them, changing pointers to them to go
> to a single copy. I have now modified the code to embed the hit ID's in
> the tracker hits, so I don't have to clean up. And no crash.
> 
>  Is my conclusion on what root I/O is doing correct? How would one do
> cleanup in this case if one had to use a pointer to the objects?
> 
> Richard

Hi Richard,
Yes, The Root I/O mechanism makes sure that only one copy of an
object is stored when this object has multiple references.
When reading the object back, all references are correctly restored.
Please refer to my answer to Christoph Borgmeier about using
reference counts in destructors.

Rene Brun



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