Boost C++ Libraries: Ticket #8007: Possible memory leak in filesystem::copy() https://svn.boost.org/trac10/ticket/8007 <p> I executed my program in valgrind to try to find out some memory leaks and I discovered one in boost::filesystem::copy(). </p> <p> My code is something like this: </p> <pre class="wiki">namespace fs = boost::filesystem; std::string from("file1"), to("file2"); // where from and to are regular files try { fs::copy(from,to); // leak here } catch(fs::filesystem_error) { // treat exception } </pre><p> The backtrace I could get with valgrind is: </p> <pre class="wiki"> ==4966== 32,768 bytes in 1 blocks are definitely lost in loss record 1,463 of 1,516 ==4966== at 0x4C2BBF7: operator new[](unsigned long) (vg_replace_malloc.c:363) ==4966== by 0x10A09C1: boost::filesystem::detail::copy(boost::filesystem::path const&amp;, boost::filesystem::path const&amp;, boost::system::error_code*) (in /old ==4966== by 0x109A501: boost::filesystem::copy(boost::filesystem::path const&amp;, boost::filesystem::path const&amp;) (operations.hpp:367) ==4966== by 0x109A26B: System::copyFile(std::string const&amp;, std::string const&amp;) (system.cpp:78) </pre><p> Where System::copyFile(string,string) is a class from my system, which basically calls the above code. </p> <p> I'm using Ubuntu 12.04 amd64 with boost 1.52 compiled by myself. I'm also using jemalloc as memory allocator. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8007 Trac 1.4.3 anonymous Thu, 07 Feb 2013 12:17:43 GMT summary changed https://svn.boost.org/trac10/ticket/8007#comment:1 https://svn.boost.org/trac10/ticket/8007#comment:1 <ul> <li><strong>summary</strong> <span class="trac-field-old">Possibly memory leak in filesystem::copy()</span> → <span class="trac-field-new">Possible memory leak in filesystem::copy()</span> </li> </ul> Ticket anonymous Tue, 02 Jan 2018 12:14:24 GMT <link>https://svn.boost.org/trac10/ticket/8007#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8007#comment:2</guid> <description> <p> Is there any update on this issue? I observe that every time I call filesystem::copy, my app has a jump in memory consumption. Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Sat, 24 Nov 2018 16:33:37 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8007#comment:3 https://svn.boost.org/trac10/ticket/8007#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">worksforme</span> </li> </ul> <p> I cannot reproduce the leak with the current develop (effectively, Boost 1.69) and gcc 8.2. Valgrind shows no leaks. </p> Ticket