Fixing a serious memory leak
authorlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 30 Oct 2009 09:54:00 +0000 (09:54 +0000)
committerlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 30 Oct 2009 09:54:00 +0000 (09:54 +0000)
MUON/AliMUON2DMapIterator.cxx
MUON/AliMUON2DMapIteratorByI.cxx
MUON/MUONTRKOCCda.cxx

index a95de14..2bb027e 100644 (file)
@@ -59,6 +59,8 @@ AliMUON2DMapIterator::operator=(const TIterator& /*rhs*/)
 AliMUON2DMapIterator::~AliMUON2DMapIterator()
 {
   /// dtor
+  delete fIter1;
+  delete fIter2;
 }
 
 //_____________________________________________________________________________
@@ -94,6 +96,7 @@ AliMUON2DMapIterator::Next()
   
   if (!o)
   {
+    delete fIter2;
     fIter2 = NextIterator();
     return Next();
   }
index a9c9973..2f1e093 100644 (file)
@@ -64,6 +64,8 @@ AliMUON2DMapIteratorByI::operator=(const TIterator& /*rhs*/)
 AliMUON2DMapIteratorByI::~AliMUON2DMapIteratorByI()
 {
   /// dtor
+  delete fIter1;
+  delete fIter2;
 }
 
 //_____________________________________________________________________________
@@ -101,6 +103,7 @@ AliMUON2DMapIteratorByI::Next()
   
   if (!o)
   {
+    delete fIter2;
     fIter2 = NextIterator();
     return Next();
   }  
index d5342c4..50bf0db 100644 (file)
@@ -6,7 +6,7 @@
  Run Type: PHYSICS STANDALONE
  DA Type: MON
  Number of events needed: all (or at least as much as possible...)
- Input Files:
+ Input Files: 09000094301009.10.raw
  Output Files: mch.occupancy, to be exported to the DAQ FXS
  Trigger types used: PHYSICS_EVENT
 */
 #include <sstream>
 #endif
 
+#include "AliSysInfo.h"
+
 const char* OUTPUT_FILE = "mch.occupancy";
-const char* DAVERSION = "MUONTRKOCCda v1.0";
+const char* DAVERSION = "MUONTRKOCCda v1.2 ($Id$)";
 
 //______________________________________________________________________________
 void Add(AliMUONVStore& destStore, const AliMUONVStore& srcStore)
@@ -86,7 +88,7 @@ void Add(AliMUONVStore& destStore, const AliMUONVStore& srcStore)
       {
         for ( Int_t j = 0; j  < source->Dimension(); ++j ) 
         {
-          dest->SetValueAsInt(i,j,dest->ValueAsInt(i,j)+source->ValueAsInt(i,j));
+          dest->SetValueAsIntFast(i,j,dest->ValueAsIntFast(i,j)+source->ValueAsIntFast(i,j));
         }
       }
     }
@@ -207,28 +209,34 @@ int main(int argc, char **argv)
       status=monitorGetEventDynamic((void **)&event);
       if (status!=0)
       {
-       printf("MCH Occupancy DA ERROR: %s\n", monitorDecodeError(status));
-       break;
+        printf("MCH Occupancy DA ERROR: %s\n", monitorDecodeError(status));
+        delete event;
+        break;
       }
 
       /* check shutdown condition */
-      if (daqDA_checkShutdown()) break;
-      
-// Check if one gets the event properly
-      if (status!=0)
+      if (daqDA_checkShutdown())
       {
-        printf("MCH Occupancy DA ERROR: monitorGetEventDynamic() failed: %s\n", monitorDecodeError(status));
-        return -1;
+        delete event;
+        break;
       }
-
+      
       /* retry if got no event */
       if (event==NULL) continue;
 
       ++numberOfEvents;
 
       eventT=event->eventType;
-      if ((eventT == END_OF_RUN)||(eventT == END_OF_RUN_FILES)) break;
-      if (eventT != PHYSICS_EVENT) continue;
+      if ((eventT == END_OF_RUN)||(eventT == END_OF_RUN_FILES)) 
+      {
+        delete event;
+        break;
+      }
+      if (eventT != PHYSICS_EVENT) 
+      {
+        delete event;
+        continue;
+      }
                  
       ++numberOfPhysicsEvent;
       
@@ -239,6 +247,8 @@ int main(int argc, char **argv)
         if ( runNumber != 0 ) 
         {
           cout << "Uh oh. That's bad... Changing of run number ???" << endl;
+          delete event;
+          delete rawReader;
           return -9999;
         }
         runNumber = rawReader->GetRunNumber();
@@ -247,7 +257,6 @@ int main(int argc, char **argv)
       AliMUONRawStreamTrackerHP stream(rawReader);
       
       stream.DisableWarnings();
-      stream.EnabbleErrorLogger();
       
       oneEventData.Clear();
       
@@ -282,9 +291,16 @@ int main(int argc, char **argv)
       {
         ++numberOfBadEvents;
       }
-    }
-    
-    delete rawReader;
+
+      if ( numberOfEvents % 10 == 0 ) 
+      {
+        AliSysInfo::AddStamp(Form("Event%d",numberOfEvents),1,numberOfEvents,-1);
+      }
+      
+      delete event;
+      
+      delete rawReader;
+    }    
   }