Boost C++ Libraries: Ticket #7156: interprocess buffer streams leak memory on construction https://svn.boost.org/trac10/ticket/7156 <p> All of the boost::interprocess::*bufferstream classes leak memory on construction. Using our own, in-house leak checker, we discovered it's the following call for all classes: </p> <blockquote> <p> basic_ios_t::init(&amp;m_buf); </p> </blockquote> <p> This leak only happens on Windows (seen with VS 2008 and VS 2010). We didn't see the problem with g++ 4.4.5 on Linux, nor with g++ 4.2.1 on Macintosh. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7156 Trac 1.4.3 Jonathan Jones <jonathan.jones@…> Fri, 20 Jul 2012 19:15:22 GMT attachment set https://svn.boost.org/trac10/ticket/7156 https://svn.boost.org/trac10/ticket/7156 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bufferstream_leak.cpp</span> </li> </ul> <p> Very crude program which demonstrates the leak. Bufferstream types are constructed in a loop along with an int on the heap. The address of the integer advances with each iteration. </p> Ticket Jonathan Jones <jonathan.jones@…> Fri, 20 Jul 2012 19:18:04 GMT attachment set https://svn.boost.org/trac10/ticket/7156 https://svn.boost.org/trac10/ticket/7156 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bufferstream.hpp.patch</span> </li> </ul> <p> Patch which seems to fix the leak. </p> Ticket Sorin Fetche <sorin.fetche@…> Tue, 16 Oct 2012 23:50:05 GMT <link>https://svn.boost.org/trac10/ticket/7156#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7156#comment:1</guid> <description> <p> The same leak appears in vectorstream family of classes, too. Tested with Boost 1.51. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 21 Aug 2013 06:30:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7156#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7156#comment:2</guid> <description> <p> We are also facing this issue. please fix this in the official boost release. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Tue, 03 Sep 2013 21:58:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7156#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7156#comment:3</guid> <description> <p> This is a known problem of the MSVC STL implementation. However, basic_ios::init call should be called only once, as the standard does not give any guarantee to allow calling it twice (MSVC STL leaks in this case). As pointed in <a class="ext-link" href="http://accu.org/index.php/journals/264"><span class="icon">​</span>http://accu.org/index.php/journals/264</a> we need to take of a potentially throwing custom streambuf so that basic_ios is not destroyed without being initialized. This is not a problem for bufferstream (has nothrow constructors) but it could affect vectorstream. In this second case a null streambuf will be passed to initialize basic_[i/o]stream, which will call basic_ios::init. After that, the streambuf will be replaced with vectorstream. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Tue, 03 Sep 2013 22:03:11 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7156#comment:4 https://svn.boost.org/trac10/ticket/7156#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/85555" title="Fixes #7156">[85555]</a>) Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7156" title="#7156: Bugs: interprocess buffer streams leak memory on construction (closed: fixed)">#7156</a> </p> Ticket