Boost C++ Libraries: Ticket #9108: flat_multimap leaks on insert(Iterator, Iterator) https://svn.boost.org/trac10/ticket/9108 <p> Reproducer: </p> <p> #include &lt;iostream&gt; #include &lt;boost/container/flat_map.hpp&gt; </p> <p> typedef boost::container::flat_multimap&lt;int,int&gt; <a class="missing wiki">IntMap</a>; </p> <p> class <a class="missing wiki">MapTest</a> { public: </p> <blockquote> <p> <a class="missing wiki">MapTest</a>() {} <a class="missing wiki">MapTest</a>(<a class="missing wiki">IntMap</a> const &amp;map) : </p> <blockquote> <p> _map(map) { _map.insert(map.begin(), map.end()); </p> </blockquote> <p> } <a class="missing wiki">IntMap</a> const&amp; getMap() {return _map; } </p> </blockquote> <p> private: </p> <blockquote> <p> <a class="missing wiki">IntMap</a> _map; </p> </blockquote> <p> }; </p> <p> int main(int argc, char *argv[]) { </p> <blockquote> <p> using std::cout; using std::endl; </p> </blockquote> <blockquote> <p> <a class="missing wiki">IntMap</a> iMap; for(int i = 0; i &lt; 1000; i++) { </p> <blockquote> <p> iMap.emplace(i, i); </p> </blockquote> <p> } </p> </blockquote> <blockquote> <p> <a class="missing wiki">MapTest</a> map(iMap); for(auto const &amp;kvPair : map.getMap()) { </p> <blockquote> <p> cout &lt;&lt; kvPair.first &lt;&lt; " : " &lt;&lt; kvPair.second &lt;&lt; endl; </p> </blockquote> <p> } return 0; </p> </blockquote> <p> } </p> <p> Valgrind Output: </p> <p> ==15820== ==15820== HEAP SUMMARY: ==15820== in use at exit: 8,000 bytes in 1 blocks ==15820== total heap usage: 20 allocs, 19 frees, 49,624 bytes allocated ==15820== ==15820== 8,000 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==15820== at 0x4A068F3: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==15820== by 0x4016EF: MapTest::<a class="missing wiki">MapTest</a>(boost::container::flat_multimap&lt;int, int, std::less&lt;int&gt;, std::allocator&lt;std::pair&lt;int, int&gt; &gt; &gt; const&amp;) (in /home/abaxter/Projects/Du/apollo-build/bin/sandbox) ==15820== by 0x4013B9: main (in /home/abaxter/Projects/Du/apollo-build/bin/sandbox) ==15820== ==15820== LEAK SUMMARY: ==15820== definitely lost: 8,000 bytes in 1 blocks ==15820== indirectly lost: 0 bytes in 0 blocks ==15820== possibly lost: 0 bytes in 0 blocks ==15820== still reachable: 0 bytes in 0 blocks ==15820== suppressed: 0 bytes in 0 blocks ==15820== </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9108 Trac 1.4.3 adam.m.baxter@… Thu, 12 Sep 2013 20:18:11 GMT attachment set https://svn.boost.org/trac10/ticket/9108 https://svn.boost.org/trac10/ticket/9108 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">sandbox.cpp</span> </li> </ul> <p> Reproducer program </p> Ticket Adam Baxter <adam.m.baxter@…> Thu, 12 Sep 2013 20:20:07 GMT attachment set https://svn.boost.org/trac10/ticket/9108 https://svn.boost.org/trac10/ticket/9108 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_error.txt</span> </li> </ul> <p> Valgrind error message </p> Ticket Adam Baxter <adam.m.baxter@…> Thu, 12 Sep 2013 20:22:08 GMT <link>https://svn.boost.org/trac10/ticket/9108#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9108#comment:1</guid> <description> <p> Apparently the copy got butchered as I forgot to do any formatting. I've attached the sandbox program and valgrind message to this ticket. </p> <p> While the program does a nonsensical thing, it was the only way I could get the bug to reproduce in something so simple </p> </description> <category>Ticket</category> </item> <item> <author>Adam Baxter <adam.m.baxter@…></author> <pubDate>Thu, 12 Sep 2013 20:28:22 GMT</pubDate> <title>summary changed https://svn.boost.org/trac10/ticket/9108#comment:2 https://svn.boost.org/trac10/ticket/9108#comment:2 <ul> <li><strong>summary</strong> <span class="trac-field-old">flat_map leaks on insert(Iterator, Iterator)</span> → <span class="trac-field-new">flat_multimap leaks on insert(Iterator, Iterator)</span> </li> </ul> Ticket Adam Baxter <adam.m.baxter@…> Thu, 12 Sep 2013 21:02:41 GMT <link>https://svn.boost.org/trac10/ticket/9108#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9108#comment:3</guid> <description> <p> I have proof that a similar thing happens with flat maps, but I'm unable to successfully create a reproducer at this point. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Thu, 12 Sep 2013 21:46:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9108#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9108#comment:4</guid> <description> <p> I just noticed that this is not a flat_xxx problem but vector's problem. The reserve() function leaks memory. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Thu, 12 Sep 2013 21:50:40 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9108#comment:5 https://svn.boost.org/trac10/ticket/9108#comment:5 <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/85658" title="Fixes #9108">[85658]</a>) Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9108" title="#9108: Bugs: flat_multimap leaks on insert(Iterator, Iterator) (closed: fixed)">#9108</a> </p> Ticket Adam Baxter <adam.m.baxter@…> Thu, 12 Sep 2013 21:56:41 GMT <link>https://svn.boost.org/trac10/ticket/9108#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9108#comment:6</guid> <description> <p> Thanks! </p> </description> <category>Ticket</category> </item> </channel> </rss>