<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to 2: Memory leak on Windows</title><link href="https://sourceforge.net/p/threadpool/bugs/2/" rel="alternate"/><link href="https://sourceforge.net/p/threadpool/bugs/2/feed.atom" rel="self"/><id>https://sourceforge.net/p/threadpool/bugs/2/</id><updated>2009-04-06T00:18:37Z</updated><subtitle>Recent changes to 2: Memory leak on Windows</subtitle><entry><title>Memory leak on Windows</title><link href="https://sourceforge.net/p/threadpool/bugs/2/" rel="alternate"/><published>2009-04-06T00:18:37Z</published><updated>2009-04-06T00:18:37Z</updated><author><name>Anonymous</name><uri>https://sourceforge.net/u/userid-None/</uri></author><id>https://sourceforge.netabefcca9c785a00a4575b9247dcc56ceeeca1ef1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Using Visual Studio 9, we have detected memory leaks when using the threadpool library. Unfortunately, we do not have the time right now to debug it for you, so I am posting this in the hopes that you can take a look and maybe it is a quick fix for you. Basically, this method:&lt;/p&gt;
&lt;p&gt;static void create_and_attach(shared_ptr&amp;lt;pool_type&amp;gt; const &amp;amp; pool)&lt;br /&gt;
{&lt;br /&gt;
shared_ptr&amp;lt;worker_thread&amp;gt; worker(new worker_thread(pool));&lt;br /&gt;
if(worker)&lt;br /&gt;
{&lt;br /&gt;
worker-&amp;gt;m_thread.reset(new boost::thread(bind(&amp;amp;worker_thread::run, worker)));&lt;br /&gt;
}&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;creates new worker threads. As best I can tell, this is where the memory is being leaked. It looks like the worker and/or the pool are not getting released properly. I looked through and see that you are using shared pointers, so maybe the reference count is not getting decremented properly. Again, I haven't had the time to look more closely at it. To reproduce, basically just use this code (run it from Visual Studio):&lt;/p&gt;
&lt;p&gt;#include &amp;lt;boost/threadpool.hpp&amp;gt;&lt;/p&gt;
&lt;p&gt;#ifdef WIN32&lt;br /&gt;
#include &amp;lt;crtdbg.h&amp;gt;&lt;br /&gt;
#endif&lt;/p&gt;
&lt;p&gt;int main()&lt;br /&gt;
{&lt;br /&gt;
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );&lt;/p&gt;
&lt;p&gt;boost::threadpool::pool pool( 1 );&lt;/p&gt;
&lt;p&gt;return 0;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;Please let me know if you need any clarification or additional information. Thanks!&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>