From 89354d0a0ce6fbb22ff262658045cdb8796ff6fd Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Fri, 04 May 2018 20:52:05 +0000
Subject: [PATCH] Fixed memory leaks. And fixes for Web-camera and IP-camera.

---
 src/detector.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/detector.c b/src/detector.c
index a942395..e891cd7 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -1,3 +1,8 @@
+#ifdef _DEBUG
+#include <stdlib.h> 
+#include <crtdbg.h>  
+#endif
+
 #include "network.h"
 #include "region_layer.h"
 #include "cost_layer.h"
@@ -1107,6 +1112,22 @@
 #endif
         if (filename) break;
     }
+
+	// free memory
+	free_ptrs(names, net.layers[net.n - 1].classes);
+	free_list(options);
+
+	int i;
+	const int nsize = 8;
+	for (j = 0; j < nsize; ++j) {
+		for (i = 32; i < 127; ++i) {
+			free_image(alphabet[j][i]);
+		}
+		free(alphabet[j]);
+	}
+	free(alphabet);
+
+	free_network(net);
 }
 
 void run_detector(int argc, char **argv)

--
Gitblit v1.10.0