i/o of objects with multiple references

From: Sue Kasahara <schubert_at_hep.umn.edu>
Date: Sun, 29 Jan 2006 16:02:31 -0600


Hi roottalk,
I have an example of a data structure that doesn't behave the way I would expect it to behave on i/o, and I'm wondering if you can help me understand what should be done. One of our record types has an odd structure due to historical reasons, so I apologize in advance for what I'm about to show you. A simplified version of this record (SimRecord) is in the tar file, and it has:
  A TObjArray containing:

     i)a TClonesArray of Hit's.
    ii)a Signal object which has a std::map<const Hit*, Float_t weight>

       data member containing a list of Hit ptrs which are a subset of those
       contained in the TClonesArray.

The Signal does not have ownership of the Hit's, which are all owned by the TClonesArray.
The entire TObjArray is written out to one branch of a root TTree. I find that on input, the range of Hit ptr addresses in the Signal map do not match those stored in the TClonesArray, indicating that multiple referencing to individual Hit objects were not reconstructed properly on input. This causes
a memory leak on input.
  This is not the behavior that I would expect given that both the TClonesArray
and Signal object were written out to the same TObjArray data branch.   Is there a reason for this, and is there a way to properly input the data while
avoiding a memory leak, given that we already have a large number of files with
data stored in this format?
The tar file contains a script testwrt.C to create a small data file, and testrd.C
to read the file, to illustrate the problem. I am using root development, dated Jan. 22, 2006, on linux. Thanks for your help in advance.
Regards,
-Sue

Received on Sun Jan 29 2006 - 23:03:19 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET