Hi Michael, Are you using TBranchObject::SetAutoDelete ? See explanation at: http://root.cern.ch/root/htmldoc/TBranchObject.html#TBranchObject:SetAutoDelete Rene Brun Michael Kuss wrote: > > Hi Rene, > > we (Heather Kelly of GSFC, one of the designers of the GLAST event > classes, and me, just a user) did more studies concerning the memory leak > problem I had reported two weeks ago. > > 1) Having the class constructors and destructors print a statement when > called one can see that the destructors are never called during > CopyEntries. Because the loop over events is inside CopyEntries we cannot > call the destructors explicitely in the program. The constructor is > called by b>>obj in TObjArray::Streamer. > > Heather wrote: > > > I did a little test based on your script...where I had the Event destructor > > print out a message when it was called. During the call to CopyEntries, > > the Event destructor is never > > called at all. This was done using Root 2.25/03. Perhaps things are > > different in Root 3.00...or perhaps CopyEntries is supposed to handle the > > memory deallocation in some other manner? > > 2) I modified my code to explicitly loop over events, not to use > CopyEntries. At the end of each loop, I call Clean(), and everything is > being deleted properly before then next event is parsed. Thus, the > destructors work properly, they are simply never called. > > 3) > > > int nEntries = m_CAL->GetEntries(); > > for (int i=0; i<nEntries; i++) > > delete m_CAL->At(i); > > m_CAL->Clear(); > > by > > m_CAL->Delete(); > > Heather also had a comment to the destructors: > > > When TBEvent was originally written, we were using Root 2.22/10. At that time, > > the destructors were implemented as Rene suggested, using m_TKR->Delete(). However, > > we ran into some problems. Some of our "small" objects were being allocated on the > > stack rather than the heap. When the call to Delete was made, those items on the > > stack were not deallocated. This is why our destructors were implemented as they are > > to explicitly remove all objects. You are now using Root 3.00 - is this no longer a problem? > > Cheers, > > Michael
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:38 MET