Hi Rene et al,
Rene Brun <Rene.Brun@cern.ch> wrote concerning
Re: [ROOT] static fgTracks in /test/Event.h [Mon, 13 Jan 2003 21:33:51 +0100 (MET)]
----------------------------------------------------------------------
> Hi Carlos,
>
> I recommend the creation of
> static TClonesArray *fgTracks[2]; //or higher dimension
> TClonesArray *fTracks[2];
>
> In the Event example, we use a static TClonesArray *fgTracks.
> In principle, this pointer should be in a Run class.
> The point is that this array should be created only once and not
> for each event to take advantage of the TClonesArray.
Wouldn't it be better if TClonesArray used a std::vector with a custom
allocator internally. In that way, memory could be shared between
multiple instantations of the same kind of TClonesArray.
class TClonesArray : public TCollection {
...
std::vector<?, Root::CloneAllocator<?> > fElements;
...
};
where Root::ClonesAlloc is an allocator similar to the default
allocator in the GNU libstdc++v3 (which pools memory too), but shared
between all TClonesArray's of the same kind (A singleton, as suggested
earlier).
In fact, I think all the TCollection classes should use std::vector
rather than plain old arrays, as you'll then take advantage of the
algorithms implmented in the library, including threadsafety, and
other such fancy stuff. Also note, that std::vector is gaurantied to
be continues in memory, so it can be used directly instead of a plain
array.
Yours,
___ | Christian Holm Christensen
|_| | -------------------------------------------------------------
| | Address: Sankt Hansgade 23, 1. th. Phone: (+45) 35 35 96 91
_| DK-2200 Copenhagen N Cell: (+45) 24 61 85 91
_| Denmark Office: (+45) 353 25 305
____| Email: cholm@nbi.dk Web: www.nbi.dk/~cholm
| |
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:08 MET