summaryrefslogtreecommitdiff
blob: 26d89d1d5c2512065dd4466ee054337dd77b7c79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Fix memleak due circular references blocking garbage collection.

http://www.cplusplus.com/forum/general/56971/ provides a testcase for a memory
leak with the threadpool due to shared_ptr usage.

I really needed threadpool to work for me, so I traced & fixed it as best as
possible. When the threadpool is being destroyed, your threads should have
terminated already. Do so deliberately if not done yet, so that they free the
memory.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>

--- threadpool/boost/threadpool/detail/pool_core.hpp
+++ threadpool/boost/threadpool/detail/pool_core.hpp
@@ -150,6 +150,7 @@
     /// Destructor.
     ~pool_core()
     {
+		terminate_all_workers(true);
     }
 
     /*! Gets the size controller which manages the number of threads in the pool.