TObjArray and Delete

From: Chiara Zampolli <Chiara.Zampolli_at_bo.infn.it>
Date: Mon, 25 Jul 2011 09:06:23 +0200


Dear all,

        According to the ROOT reference guide, when you have a TObjArray which is owner of its own objects, the call to the destructor of the TObjArray is enough to delete also its objects. Why, then, the pointer to the object is still not null after that (even if not valid)? E.g.:

root [0] TObjArray* a = new TObjArray()        
root [1] a->SetOwner(1)    -----------> OWNER = TRUE                    
root [2] TH1F* h0 = new TH1F("h0","h0",10,0,10)
root [3] h0->Fill(2)                           

(Int_t)3

root [4] h0->Fill(2)
(Int_t)3

root [5] h0->Fill(2)
(Int_t)3
root [6] a->Add(h0)                            
root [7] h0->GetEntries()                      

(const Double_t)3.00000000000000000e+00
root [8] delete a ----------> DESTROYING THE TOBJARRAY
root [9] h0
(class TH1F*)0x102c3c010 ---------> THE ADDRESS SEEMS OK
root [10] h0->GetEntries()

I am asking this because in some piece of code, I do exactly that (declaring the TObjArray as owner of its object, and then NOT calling TObjArray::Delete(), but only the destructor), but I am not 100% now that this is enough.

Thanks for your help.

Regards,

        Chiara Received on Mon Jul 25 2011 - 09:06:33 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 25 2011 - 11:50:01 CEST