From 8d7e04cb8e456740a6238207bfe5faad5e468523 Mon Sep 17 00:00:00 2001 From: Dongxiao Date: Wed, 20 Sep 2023 16:34:39 +0800 Subject: [PATCH] fixed closest_set memory leak --- src/core/task/closest_set.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/task/closest_set.h b/src/core/task/closest_set.h index d10c34f..6be1fd3 100644 --- a/src/core/task/closest_set.h +++ b/src/core/task/closest_set.h @@ -52,13 +52,13 @@ class ClosestSet { closest[cn->getId()] = cn; if (closest.size() > capacity) { auto last = std::prev(closest.cend()); - closest.erase(last); - if (last->second == cn) { insertAttemptsSinceTailModification++; } else { insertAttemptsSinceTailModification = 0; } + + closest.erase(last->first); } const auto head = closest.cbegin()->second; @@ -102,7 +102,7 @@ class ClosestSet { private: const Id& target; - int capacity; + int capacity {0}; std::map> closest {};