<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 2: Memory leak on Windows</title><link>https://sourceforge.net/p/threadpool/bugs/2/</link><description>Recent changes to 2: Memory leak on Windows</description><atom:link href="https://sourceforge.net/p/threadpool/bugs/2/feed.rss" rel="self"/><language>en</language><lastBuildDate>Mon, 06 Apr 2009 00:18:37 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/threadpool/bugs/2/feed.rss" rel="self" type="application/rss+xml"/><item><title>Memory leak on Windows</title><link>https://sourceforge.net/p/threadpool/bugs/2/</link><description>&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;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Mon, 06 Apr 2009 00:18:37 -0000</pubDate><guid>https://sourceforge.netabefcca9c785a00a4575b9247dcc56ceeeca1ef1</guid></item></channel></rss>