From 3e4430c0898403c640654fc295e7d79a55290366 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sat, 23 Mar 2019 15:43:00 +0100 Subject: [PATCH] Fix huge memory link in Collection iterator. * Bug: In Hurricane::Collection::iterator, the iterator use a locator from a getLocator() not wrapped inside an auto_pointer like GenericLocator. So the destructor of the iterator must take care of the deletion. This was showing more and more as we converted forEach() into the C++ 11 for syntax. Seems to decrease the memory use by almost a factor 2... * Bug: In Dijkstra::_cleanup(), as a double security, cleanup the queue. --- anabatic/src/Dijkstra.cpp | 1 + hurricane/src/hurricane/hurricane/Collection.h | 1 + 2 files changed, 2 insertions(+) diff --git a/anabatic/src/Dijkstra.cpp b/anabatic/src/Dijkstra.cpp index 2fef02c0..207af8d8 100644 --- a/anabatic/src/Dijkstra.cpp +++ b/anabatic/src/Dijkstra.cpp @@ -1779,6 +1779,7 @@ namespace Anabatic { //_checkEdges(); _sources.clear(); _targets.clear(); + _queue.clear(); _searchArea.makeEmpty(); _connectedsId = 0; } diff --git a/hurricane/src/hurricane/hurricane/Collection.h b/hurricane/src/hurricane/hurricane/Collection.h index 9a6042ac..1f3b5664 100644 --- a/hurricane/src/hurricane/hurricane/Collection.h +++ b/hurricane/src/hurricane/hurricane/Collection.h @@ -206,6 +206,7 @@ template class Collection { class iterator { public: iterator ( Locator* l ) : _locator(l) {} + ~iterator () { delete _locator; } bool operator== ( const iterator& o) const { return not (*this != o); } iterator& operator++ () { _locator->progress(); return *this; } Type operator* () { return _locator->getElement(); }