From 5579b0bec5e76a8a22f304c9be337745b378b4fd Mon Sep 17 00:00:00 2001
From: Andrews Cordolino Sobral <andrewssobral@gmail.com>
Date: Sun, 31 Jul 2022 01:22:02 +0200
Subject: [PATCH] [important] Fixed memory leak on Fuzzy-based algorithms

2 algorithms: FuzzyChoquetIntegral, FuzzySugenoIntegral
---
 src/algorithms/FuzzyChoquetIntegral.cpp | 4 ++++
 src/algorithms/FuzzySugenoIntegral.cpp  | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/src/algorithms/FuzzyChoquetIntegral.cpp b/src/algorithms/FuzzyChoquetIntegral.cpp
index 96fa890..18494f8 100644
--- a/src/algorithms/FuzzyChoquetIntegral.cpp
+++ b/src/algorithms/FuzzyChoquetIntegral.cpp
@@ -152,6 +152,10 @@ void FuzzyChoquetIntegral::process(const cv::Mat &img_input, cv::Mat &img_output
     cv::Mat img_updated_background_f3 = cv::cvarrToMat(updated_background_f3);
     img_updated_background_f3.copyTo(img_background_f3);
 
+    cvReleaseImage(&input_f3);
+    cvReleaseImage(&input_f1);
+    cvReleaseImage(&background_f3);
+    cvReleaseImage(&background_f1);
     cvReleaseImage(&lbp_input_f1);
     cvReleaseImage(&lbp_background_f1);
     cvReleaseImage(&sim_texture_f1);
diff --git a/src/algorithms/FuzzySugenoIntegral.cpp b/src/algorithms/FuzzySugenoIntegral.cpp
index a43dfba..ff03451 100644
--- a/src/algorithms/FuzzySugenoIntegral.cpp
+++ b/src/algorithms/FuzzySugenoIntegral.cpp
@@ -151,6 +151,10 @@ void FuzzySugenoIntegral::process(const cv::Mat &img_input, cv::Mat &img_output,
     cv::Mat img_updated_background_f3 = cv::cvarrToMat(updated_background_f3);
     img_updated_background_f3.copyTo(img_background_f3);
 
+    cvReleaseImage(&input_f3);
+    cvReleaseImage(&input_f1);
+    cvReleaseImage(&background_f3);
+    cvReleaseImage(&background_f1);
     cvReleaseImage(&lbp_input_f1);
     cvReleaseImage(&lbp_background_f1);
     cvReleaseImage(&sim_texture_f1);
-- 
GitLab