memory usage optimised
authorsgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Sep 2011 19:58:33 +0000 (19:58 +0000)
committersgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Sep 2011 19:58:33 +0000 (19:58 +0000)
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFEmulatorComponent.cxx
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFSupport.cxx
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFSupport.h

index e6fe1c3..4cb5a66 100644 (file)
@@ -498,7 +498,8 @@ int AliHLTTPCHWCFEmulatorComponent::DoEvent( const AliHLTComponentEventData& evt
       std::auto_ptr<AliHLTTPCClusterMCLabel> allocOutMC(new AliHLTTPCClusterMCLabel[nOutputMC+1]);
       
       if( !outBlock.get() || !allocOutMC.get() ){
-       return -ENOMEM;
+       iResult=-ENOMEM;
+       break;
       }
 
       memset(outBlock.get(), 0, outBlockSize*sizeof(AliHLTUInt8_t));
@@ -577,6 +578,7 @@ int AliHLTTPCHWCFEmulatorComponent::DoEvent( const AliHLTComponentEventData& evt
       } else {
        HLTWarning( "Output buffer (%db) is too small, required %db", maxSize, size+outSize);
        iResult=-ENOSPC;
+       break;
       }
 
       if( fDoMC && outMC && outMC->fCount>0 ){
@@ -596,12 +598,14 @@ int AliHLTTPCHWCFEmulatorComponent::DoEvent( const AliHLTComponentEventData& evt
        } else {        
          HLTWarning( "Output buffer (%db) is too small, required %db", maxSize, size+s);
          iResult=-ENOSPC;          
+         break;
        }
       }
     }
   
   fBenchmark.Stop(0);  
   HLTInfo(fBenchmark.GetStatistics());
+  fCFSupport.ReleaseEventMemory();
   return iResult;
 }
 
index 1cd5077..6060f4e 100644 (file)
@@ -65,8 +65,7 @@ AliHLTTPCHWCFSupport::~AliHLTTPCHWCFSupport()
   // see header file for class documentation
   for( int i=0; i<fgkNSlices; i++ )
     for( int j=0; j<fgkNPatches; j++ ) delete[] fMapping[i][j];
-  delete[] fEventMemory;
-  delete[] fEventMCMemory;
+  ReleaseEventMemory(); 
 }
 
 AliHLTTPCHWCFSupport::AliHLTTPCHWCFSupport(const AliHLTTPCHWCFSupport&)
@@ -84,6 +83,16 @@ AliHLTTPCHWCFSupport& AliHLTTPCHWCFSupport::operator=(const AliHLTTPCHWCFSupport
 }
 
 
+void AliHLTTPCHWCFSupport::ReleaseEventMemory()
+{
+  // clean up 
+  if( fEventMemory ) delete[] fEventMemory;
+  if( fEventMCMemory )delete[] fEventMCMemory;
+  fEventMemory = 0;
+  fEventMCMemory = 0;
+}
+
+
 const AliHLTUInt32_t *AliHLTTPCHWCFSupport::GetMapping( int slice, int patch )
 { 
   // see header file for class documentation
@@ -311,8 +320,7 @@ int AliHLTTPCHWCFSupport::CreateRawEvent
   // MC labels are provided if possible  
   //
 
-  delete[] fEventMemory;
-  delete[] fEventMCMemory;
+  ReleaseEventMemory();
   
   rawEvent = 0;
   rawEventSize32 = 0;
@@ -408,6 +416,7 @@ int AliHLTTPCHWCFSupport::CreateRawEvent
       if( !fEventMCMemory ){
        HLTWarning("Not enougth memory: can not allocate %d bytes",totalNMC*sizeof(AliHLTTPCClusterMCLabel));
        delete[] fEventMemory;
+       fEventMemory = 0;
        return 0;
       }
 
index c5a1251..2d7047c 100644 (file)
@@ -46,6 +46,9 @@ class AliHLTTPCHWCFSupport : public AliHLTLogging
   /** method to check raw data */
   int CheckRawData( const AliHLTUInt32_t *buffer, unsigned long bufferSize32, int patch, int slice );
 
+  /** clean up */
+  void ReleaseEventMemory();
+
  
  private: