Re: autodeletion of member or arrays, list... ?

From: Krzysztof Wozniak (wozniak@chall.ifj.edu.pl)
Date: Thu Feb 17 2000 - 15:11:31 MET


On Thu, 17 Feb 2000, Vincent Colin de Verdiere wrote:

> Hi Rooters,
> 
> Currently, from what I have seen, if I have a TObjArray* A, when I delete
> it, its members are not deleted unless I run A->Delete() before. The same
> applies to lists. I wonder if it would be possible to add some "adoption"
> mecanism which would give the responsibility of destroying objects to the
> array when it is deleted.
> 
> Then for deletion, people would only need to delete the array.. It saves
> one line of code ! ;-)  and it costs several lines in the array class plus
> a boolean value to activate this behaviour. ;-(
> 
> But, the main point is that it would save, to my view, a lot of memory
> loss mistakes: 
>   when you set a new value to a bin of the array. A.At(x, i) would delete
> previous object if present. It has a cost and should not be set by default
> but is very usefull... I have used to it in another "somewhat" similar
> system and it was very pratical !
> 
Yes, it can be practical in the case, when you put the object to 
ONLY ONE TObjArray. However, if the same object is stored in two
(or more) arrays, then after deleting the first array with all
objects attached to it, trying to access elements of the second array 
or during deleting the second array you obtain a nice seg. val. error
:-(((
To prevent such behaviour you have to type much more than a single line
  A->Delete();

So may be it's better to keep the present implementation?

Krzysztof 

--------------------------------------------------------------------
Email:  Krzysztof.Wozniak@ifj.edu.pl           phone: 48-12-633-3366
WWW:    http://www.ifj.edu.pl/~wozniak         fax:   48-12-633-3884
Institute of Nuclear Physics, ul. Kawiory 26A, 30-055 Krakow, Poland
--------------------------------------------------------------------



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