Commit 50b80924 authored by Thibault Allançon's avatar Thibault Allançon

bench: bitstate: fix memory leak (recycle kripke states)

* bench/bitstate/bitstate.hh: fix here
parent 87cf4a18
Pipeline #17601 failed with stage
in 58 minutes and 9 seconds
......@@ -38,19 +38,10 @@ public:
State, SuccIterator>::value,
"error: does not match the kripkecube requirements");
seen_.reserve(2000000);
todo_.reserve(100000);
bloom_filter::hash_functions_t hash_functions = {lookup3_hash};
bf_ = std::make_unique<bloom_filter>(mem_size, hash_functions);
}
~bitstate_hashing_stats()
{
// States will be destroyed by the system, so just clear map
seen_.clear();
}
void push(State s)
{
todo_.push_back({s, sys_.succ(s, tid_), state_number_});
......@@ -60,19 +51,18 @@ public:
void pop()
{
StateHash state_hash;
auto current = todo_.back();
bf_->insert(state_hash(current.s));
seen_.erase(current.s);
todo_.pop_back();
seen_.erase(current.s);
bf_->insert(state_hash_(current.s));
sys_.recycle(current.it, tid_);
}
void run()
{
state_number_ = 1;
State initial = sys_.initial(tid_);
StateHash state_hash;
push(initial);
while (!todo_.empty())
......@@ -87,7 +77,7 @@ public:
todo_.back().it->next();
bool marked = seen_.find(next) != seen_.end() ||
bf_->contains(state_hash(next));
bf_->contains(state_hash_(next));
if (marked == false)
push(next);
}
......@@ -110,6 +100,7 @@ private:
protected:
kripkecube<State, SuccIterator>& sys_;
unsigned int tid_;
StateHash state_hash_;
std::unordered_set<State, StateHash, StateEqual> seen_;
std::vector<todo__element> todo_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment