We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
file: data.hpp issue description: There is a memory leak in the pool class due to a cyclic dependency between the pool and the data classes. fix:
diff --git a/src/messages/data.hpp b/src/messages/data.hpp --- a/src/messages/data.hpp +++ b/src/messages/data.hpp @@ -61,6 +61,7 @@ template public: typedef pool<element_type> type; typedef boost::shared_ptr ptr; typedef boost::weak_ptr<type> ptr_weak; typedef typename element_type::ptr element_ptr; typedef boost::function<void()> callback_type; @@ -149,6 +150,7 @@ class data { public: typedef boost::intrusive_ptr ptr; typedef pool::ptr pool_ptr; typedef pool<data>::ptr_weak pool_weak_ptr; data(pool_ptr p, size_t s); @@ -210,7 +212,10 @@ private: if (count == 1 && s->m_live) { // recycle if endpoint exists s->m_live = false;
typedef boost::weak_ptr<type> ptr_weak;
@@ -149,6 +150,7 @@ class data { public: typedef boost::intrusive_ptr ptr; typedef pool::ptr pool_ptr;
typedef pool<data>::ptr_weak pool_weak_ptr;
data(pool_ptr p, size_t s);
@@ -210,7 +212,10 @@ private: if (count == 1 && s->m_live) { // recycle if endpoint exists s->m_live = false;
s->m_pool->recycle(ptr(const_cast<data *>(s))); pool_ptr pp = s->m_pool.lock(); if (pp != NULL) { pp->recycle(ptr(const_cast<data *>(s))); } } else if (count == 0) { boost::checked_delete(static_cast<data const *>(s)); } @@ -235,7 +240,7 @@ private: // reference counting size_t m_index; mutable boost::detail::atomic_count m_ref_count; mutable pool_ptr m_pool;
s->m_pool->recycle(ptr(const_cast<data *>(s)));
pool_ptr pp = s->m_pool.lock();
if (pp != NULL) {
pp->recycle(ptr(const_cast<data *>(s)));
} } else if (count == 0) { boost::checked_delete(static_cast<data const *>(s)); }
mutable pool_weak_ptr m_pool; mutable bool m_live; };
The text was updated successfully, but these errors were encountered:
experimenting with weak pointers references #53
6377358
No branches or pull requests
file: data.hpp
issue description: There is a memory leak in the pool class due to a cyclic dependency between the pool and the data classes.
fix:
// reference counting
size_t m_index;
mutable boost::detail::atomic_count m_ref_count;
mutable pool_weak_ptr m_pool;
mutable bool m_live;
};
The text was updated successfully, but these errors were encountered: