Re: Question about using pointers to fill TClonesArray [message #17681 is a reply to message #17679] |
Thu, 18 December 2014 21:26 |
Klaus Götzen
Messages: 293 Registered: June 2006 Location: GSI
|
first-grade participant |
From: *adsl.alicedsl.de
|
|
Hi Tobias,
thanks for pointing out the issue a bit more detailed!
Just like to give one additonal remark: If the objects stored in the TClonesArray don't allocate memory dynamically (like TString, std::vector, ...), you don't even need to call TCA->Delete(), which calls the destructor for all objects, but only TCA->Clear() which doesn't do that and thus is much faster.
However, PndTrackCand owns a std::vector, therefore Delete() has to be called I think.
Btw this is the reason, why the daughters (the only 'dynamic' quantity) of RhoCandidate are stored in an array with fixed size. Although being somehow unelegant, the destructor of RhoCandidate has never to be called by RhoFactory making it really fast. There actually was a severe memory leak before I got aware of that issue ...
Best and merry x-mas,
Klaus
|
|
|