Boost C++ Libraries: Ticket #10696: boost::container::flat_map copy constructor appears to leak https://svn.boost.org/trac10/ticket/10696 <p> The following sandbox.cpp program: </p> <pre class="wiki">#include &lt;boost/container/flat_map.hpp&gt; int main(int argc, char** argv) { boost::container::flat_map&lt;int, int&gt; myMap; boost::container::flat_map&lt;int, int&gt; myCopiedMap(myMap); return 0; } </pre><p> causes valgrind 3.9.0 to produce the following: </p> <pre class="wiki">$ valgrind --tool=memcheck --leak-check=full --show-reachable=no --undef-value-errors=no --track-origins=no --child-silent-after-fork=yes --trace-children=no ./sandbox ==12648== Memcheck, a memory error detector ==12648== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==12648== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info ==12648== Command: ./sandbox ==12648== ==12648== ==12648== HEAP SUMMARY: ==12648== in use at exit: 3,287 bytes in 86 blocks ==12648== total heap usage: 122 allocs, 36 frees, 56,978 bytes allocated ==12648== ==12648== 0 bytes in 1 blocks are definitely lost in loss record 1 of 86 ==12648== at 0x4C27965: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==12648== by 0x40410F: __gnu_cxx::new_allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt;::allocate(unsigned long, void const*) (new_allocator.h:104) ==12648== by 0x40400B: boost::container::container_detail::allocator_version_traits&lt;std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt;, 1u&gt;::allocation_command(std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt;&amp;, int, unsigned long, unsigned long, unsigned long&amp;, boost::container::container_detail::pair&lt;int, int&gt;* const&amp;) (allocator_version_traits.hpp:144) ==12648== by 0x403F0D: boost::container::container_detail::vector_alloc_holder&lt;std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt;, boost::container::container_detail::integral_constant&lt;unsigned int, 1u&gt; &gt;::allocation_command(int, unsigned long, unsigned long, unsigned long&amp;, boost::container::container_detail::pair&lt;int, int&gt;* const&amp;) (vector.hpp:395) ==12648== by 0x403D72: boost::container::container_detail::vector_alloc_holder&lt;std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt;, boost::container::container_detail::integral_constant&lt;unsigned int, 1u&gt; &gt;::vector_alloc_holder&lt;std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt; const&amp;&gt;(std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt; const&amp;, unsigned long) (vector.hpp:350) ==12648== by 0x403BF2: boost::container::vector&lt;boost::container::container_detail::pair&lt;int, int&gt;, std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt; &gt;::vector(boost::container::vector&lt;boost::container::container_detail::pair&lt;int, int&gt;, std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt; &gt; const&amp;) (vector.hpp:732) ==12648== by 0x403B34: boost::container::container_detail::flat_tree&lt;int, boost::container::container_detail::pair&lt;int, int&gt;, boost::container::container_detail::select1st&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt;, std::less&lt;int&gt;, std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt; &gt;::Data::Data(boost::container::container_detail::flat_tree&lt;int, boost::container::container_detail::pair&lt;int, int&gt;, boost::container::container_detail::select1st&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt;, std::less&lt;int&gt;, std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt; &gt;::Data const&amp;) (flat_tree.hpp:119) ==12648== by 0x403A42: boost::container::container_detail::flat_tree&lt;int, boost::container::container_detail::pair&lt;int, int&gt;, boost::container::container_detail::select1st&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt;, std::less&lt;int&gt;, std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt; &gt;::flat_tree(boost::container::container_detail::flat_tree&lt;int, boost::container::container_detail::pair&lt;int, int&gt;, boost::container::container_detail::select1st&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt;, std::less&lt;int&gt;, std::allocator&lt;boost::container::container_detail::pair&lt;int, int&gt; &gt; &gt; const&amp;) (flat_tree.hpp:207) ==12648== by 0x40399A: boost::container::flat_map&lt;int, int, std::less&lt;int&gt;, std::allocator&lt;std::pair&lt;int, int&gt; &gt; &gt;::flat_map(boost::container::flat_map&lt;int, int, std::less&lt;int&gt;, std::allocator&lt;std::pair&lt;int, int&gt; &gt; &gt; const&amp;) (flat_map.hpp:209) ==12648== by 0x4037BE: main (sandbox.cpp:6) ==12648== ==12648== LEAK SUMMARY: ==12648== definitely lost: 0 bytes in 1 blocks ==12648== indirectly lost: 0 bytes in 0 blocks ==12648== possibly lost: 0 bytes in 0 blocks ==12648== still reachable: 3,287 bytes in 85 blocks ==12648== suppressed: 0 bytes in 0 blocks ==12648== Reachable blocks (those to which a pointer was found) are not shown. ==12648== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==12648== ==12648== For counts of detected and suppressed errors, rerun with: -v ==12648== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10696 Trac 1.4.3 viboes Fri, 13 Feb 2015 18:34:36 GMT component changed; owner set https://svn.boost.org/trac10/ticket/10696#comment:1 https://svn.boost.org/trac10/ticket/10696#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Ion Gaztañaga</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">container</span> </li> </ul> Ticket Ion Gaztañaga Wed, 11 Mar 2015 20:46:36 GMT <link>https://svn.boost.org/trac10/ticket/10696#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10696#comment:2</guid> <description> <p> I can't see the problem in current versions. And your example does not seem to allocate any memory (you create empty maps). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Thu, 11 Aug 2016 09:18:21 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10696#comment:3 https://svn.boost.org/trac10/ticket/10696#comment:3 <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> An modified example allocating memory does not show any leak in the copy constructor in recent versions, so closing this bug as fixed. </p> Ticket