Gecode / gecode

Generic Constraint Development Environment
https://www.gecode.org
Other
275 stars 76 forks source link

Fixing parallel engine memory leak for issue #156 #161

Closed alex-87 closed 1 year ago

alex-87 commented 1 year ago

This fix proceeds by cleaning the Gecode::Support::DynamicQueue<Gecode::Space *, Gecode::Heap> solutions attribute of the Gecode::Search::Par::Engine<Tracer> class in the destructor. It unstacks the remaining Gecode::Space * items of the queue and explicitly deletes the objects until the queue is empty.

This fix uses the same mechanism as of gecode/search/par/pbs.hpp https://github.com/Gecode/gecode/blob/b38d85179280490b228665738c526eac31f03d9e/gecode/search/par/pbs.hpp, which deals with the same solutions attribute :

  forceinline
  CollectAll::~CollectAll(void) {
    while (!solutions.empty())
      delete solutions.pop();
  }
zayenz commented 1 year ago

Thank you for the fix, and it looks nice. All tests passed on the branch.