attempt to fix the mem leak reported in https://savannah.cern.ch/bugs/?82308 ; additi...
authormploskon <mploskon@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 21 Jun 2011 10:28:25 +0000 (10:28 +0000)
committermploskon <mploskon@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 21 Jun 2011 10:28:25 +0000 (10:28 +0000)
EMCAL/AliEMCALClusterizer.cxx
EMCAL/AliEMCALClusterizer.h
EMCAL/AliEMCALClusterizerNxN.cxx
EMCAL/AliEMCALReconstructor.cxx

index 0ae9352..bff1442 100644 (file)
@@ -158,6 +158,22 @@ AliEMCALClusterizer::~AliEMCALClusterizer()
   //Already deleted in AliEMCALReconstructor.
 
   if(fClusterUnfolding) delete fClusterUnfolding;
+
+  // make sure we delete the rec points array
+  DeleteRecPoints();
+}
+
+//____________________________________________________________________________
+void AliEMCALClusterizer::DeleteRecPoints()
+{
+  // free the cluster array
+  if (fRecPoints) 
+    {
+      AliDebug(2, "Deleting fRecPoints.");
+      fRecPoints->Delete();
+      delete fRecPoints;
+      fRecPoints = 0;
+    }
 }
 
 //____________________________________________________________________________
index b3916cf..9cbc055 100644 (file)
@@ -88,6 +88,8 @@ public:
   virtual void              SetDigitsArr(TClonesArray *arr) { fDigitsArr = arr;  }
   virtual const TObjArray  *GetRecPoints() const            { return fRecPoints; }
 
+  virtual void DeleteRecPoints();
+
 protected:
 
   virtual void MakeClusters() = 0;
index 3fae8d5..a47c200 100644 (file)
@@ -313,9 +313,11 @@ void AliEMCALClusterizerNxN::MakeClusters()
       if (fNumberOfECAClusters >= fRecPoints->GetSize()) 
         fRecPoints->Expand(2*fNumberOfECAClusters+1);
       
-      AliEMCALRecPoint *recPoint = new  AliEMCALRecPoint(""); 
-      fRecPoints->AddAt(recPoint, fNumberOfECAClusters);
-      recPoint = static_cast<AliEMCALRecPoint *>(fRecPoints->At(fNumberOfECAClusters)); 
+      (*fRecPoints)[fNumberOfECAClusters] = new AliEMCALRecPoint("") ;
+      AliEMCALRecPoint *recPoint = dynamic_cast<AliEMCALRecPoint *>( fRecPoints->At(fNumberOfECAClusters) ) ;
+      // AliEMCALRecPoint *recPoint = new  AliEMCALRecPoint(""); 
+      // fRecPoints->AddAt(recPoint, fNumberOfECAClusters);
+      // recPoint = static_cast<AliEMCALRecPoint *>(fRecPoints->At(fNumberOfECAClusters)); 
       if (recPoint) {
         fNumberOfECAClusters++;       
         recPoint->SetClusterType(AliVCluster::kEMCALClusterv1);
index af5ae92..364636f 100644 (file)
@@ -80,7 +80,9 @@ AliEMCALReconstructor::AliEMCALReconstructor()
   : fGeom(0),fCalibData(0),fPedestalData(0),fTriggerData(0x0), fMatches(0x0)
 {
   // ctor
-  
+
+  // AliDebug(2, "Mark.");  
+
   fgRawUtils = new AliEMCALRawUtils;
   
   //To make sure we match with the geometry in a simulation file,
@@ -143,7 +145,9 @@ AliEMCALReconstructor::AliEMCALReconstructor()
 AliEMCALReconstructor::~AliEMCALReconstructor()
 {
   // dtor
-  
+
+  //AliDebug(2, "Mark.");
+
   if(fGeom)              delete fGeom;
   
   //No need to delete, recovered from OCDB
@@ -255,6 +259,9 @@ void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree)
   }//not a LED event
   
   clustersTree->Fill();        
+
+  // Deleting the recpoints at the end of the reconstruction call
+  fgClusterizer->DeleteRecPoints();
 }
 
 //____________________________________________________________________________