Commit 02e31cba authored by Etienne Renault's avatar Etienne Renault
Browse files

bloemen: fix memory leaks

* spot/mc/bloemen.hh, spot/mc/mc.hh: here.
parent bc5287c7
...@@ -93,7 +93,8 @@ namespace spot ...@@ -93,7 +93,8 @@ namespace spot
iterable_uf(shared_map& map, unsigned tid): iterable_uf(shared_map& map, unsigned tid):
map_(map), tid_(tid), size_(std::thread::hardware_concurrency()), map_(map), tid_(tid), size_(std::thread::hardware_concurrency()),
nb_th_(std::thread::hardware_concurrency()), inserted_(0) nb_th_(std::thread::hardware_concurrency()), inserted_(0),
p_(sizeof(uf_element))
{ {
} }
...@@ -105,7 +106,7 @@ namespace spot ...@@ -105,7 +106,7 @@ namespace spot
unsigned w_id = (1U << tid_); unsigned w_id = (1U << tid_);
// Setup and try to insert the new state in the shared map. // Setup and try to insert the new state in the shared map.
uf_element* v = new uf_element(); uf_element* v = (uf_element*) p_.allocate();
v->st_ = a; v->st_ = a;
v->parent = v; v->parent = v;
v->next_ = v; v->next_ = v;
...@@ -119,7 +120,7 @@ namespace spot ...@@ -119,7 +120,7 @@ namespace spot
// Insertion failed, delete element // Insertion failed, delete element
// FIXME Should we add a local cache to avoid useless allocations? // FIXME Should we add a local cache to avoid useless allocations?
if (!b) if (!b)
delete v; p_.deallocate(v);
else else
++inserted_; ++inserted_;
...@@ -393,6 +394,7 @@ namespace spot ...@@ -393,6 +394,7 @@ namespace spot
unsigned size_; ///< \brief Maximum number of thread unsigned size_; ///< \brief Maximum number of thread
unsigned nb_th_; ///< \brief Current number of threads unsigned nb_th_; ///< \brief Current number of threads
unsigned inserted_; ///< \brief The number of insert succes unsigned inserted_; ///< \brief The number of insert succes
fixed_size_pool<pool_type::Unsafe> p_; ///< \brief The allocator
}; };
/// \brief This object is returned by the algorithm below /// \brief This object is returned by the algorithm below
...@@ -461,6 +463,7 @@ namespace spot ...@@ -461,6 +463,7 @@ namespace spot
todo_.push_back(w.second); todo_.push_back(w.second);
Rp_.push_back(w.second); Rp_.push_back(w.second);
++states_; ++states_;
sys_.recycle(it, tid_);
goto bloemen_recursive_start; goto bloemen_recursive_start;
} }
else if (w.first == uf::claim_status::CLAIM_FOUND) else if (w.first == uf::claim_status::CLAIM_FOUND)
......
...@@ -226,8 +226,10 @@ namespace spot ...@@ -226,8 +226,10 @@ namespace spot
stats.push_back(swarmed[i]->stats()); stats.push_back(swarmed[i]->stats());
for (unsigned i = 0; i < nbth; ++i) for (unsigned i = 0; i < nbth; ++i)
delete swarmed[i]; {
delete swarmed[i];
delete ufs[i];
}
return std::make_pair(stats, tm); return std::make_pair(stats, tm);
} }
} }
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