From b9ab51f8c58a9ab75be33872d2af0ea5dd76a886 Mon Sep 17 00:00:00 2001 From: Rahul Rewale Date: Thu, 17 Aug 2023 14:22:28 +0530 Subject: [PATCH] Release gridMap memory In planner.cpp, we allocate memory for binMap and never release it. This is then passed to voronoiDiagram.initializeMap() function, which assigns it to the gridMap member variable. In the subsequent calls to the function, we just assign this binMap or _gridMap parameter to the member variable gridMap, without releasing the existing gridMap memory. This results in memory leak. --- src/dynamicvoronoi.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dynamicvoronoi.cpp b/src/dynamicvoronoi.cpp index 198399da..b557a6ad 100644 --- a/src/dynamicvoronoi.cpp +++ b/src/dynamicvoronoi.cpp @@ -60,6 +60,12 @@ void DynamicVoronoi::initializeEmpty(int _sizeX, int _sizeY, bool initGridMap) { } void DynamicVoronoi::initializeMap(int _sizeX, int _sizeY, bool** _gridMap) { + // release memory used by existing gridMap + if (gridMap) { + for (int x=0; x