diff --git a/app/Operations/ThresholdDialog.cpp b/app/Operations/ThresholdDialog.cpp
index a8bdfd5b7b276b538ed6868d8760d685b924e002..8d2bb415fecb159142d1fa08d4ee81a310441500 100644
--- a/app/Operations/ThresholdDialog.cpp
+++ b/app/Operations/ThresholdDialog.cpp
@@ -71,8 +71,10 @@ void ThresholdDialog::updatePreview(){
         else {
             algo = new Binarization_t<GrayscaleImage::depth_t>(_spinbox1->value());
         }
-
-        _preview->setImage(algo->operator()(_image));
+        _previewImage = algo->operator()(_image);
+        _preview->setImage(_previewImage);
+        delete algo;
+        delete _previewImage;
         _preview->repaint();
     }
 
diff --git a/app/Operations/ThresholdDialog.h b/app/Operations/ThresholdDialog.h
index b0641502f7a4e534837cd9c09ce7783f53c481ad..044dd925bb643d1b97ac8743aadb14d04c28b6d9 100644
--- a/app/Operations/ThresholdDialog.h
+++ b/app/Operations/ThresholdDialog.h
@@ -64,6 +64,7 @@ class ThresholdDialog : public QDialog {
     QRadioButton* _blackButton;
     QCheckBox *_doubleBox, *_previewBox;
     ImageWidget* _preview;
+    imagein::GrayscaleImage* _previewImage;
 };
 
 #endif //!THRESHOLDDIALOG_H
diff --git a/app/Operations/ThresholdOp.cpp b/app/Operations/ThresholdOp.cpp
index fd08985a1c40a2fc0b94a711099850b5a42ee04f..8164c12626598977c672919f8e28208407790f18 100644
--- a/app/Operations/ThresholdOp.cpp
+++ b/app/Operations/ThresholdOp.cpp
@@ -40,5 +40,6 @@ void ThresholdOp::operator()(const imagein::Image* image, const std::map<const i
     }
 
     GrayscaleImage* resImg = algo->operator()(img);
+    delete algo;
     this->outImage(resImg);
 }