diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/SANSDiagnostics.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/SANSDiagnostics.cpp
index 0a199eedc635551f101433a3868c07d8b19d3ffa..6907695f5d37ad2d2db912950583d6de889e37f5 100644
--- a/Code/Mantid/MantidQt/CustomInterfaces/src/SANSDiagnostics.cpp
+++ b/Code/Mantid/MantidQt/CustomInterfaces/src/SANSDiagnostics.cpp
@@ -456,7 +456,7 @@ namespace MantidQt
             min_spec_index = aux;
         }
       }
-
+	delete map; // release memory allocated by getWorkspaceIndexToDetectorIDMap.
       if ( min_spec_index == ULONG_MAX || max_spec_index == 0){
         g_log.error()<<"Error : The instrument does not have data associated to the RectangularDetector " << rectDet->getDetectorName().toStdString()<<std::endl;
       }