Opened 6 years ago

Last modified 9 months ago

#8007 new Bugs

Possible memory leak in filesystem::copy()

Reported by: anonymous Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:


I executed my program in valgrind to try to find out some memory leaks and I discovered one in boost::filesystem::copy().

My code is something like this:

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

The backtrace I could get with valgrind is:

==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&, boost::filesystem::path const&, boost::system::error_code*) (in /old
==4966==    by 0x109A501: boost::filesystem::copy(boost::filesystem::path const&, boost::filesystem::path const&) (operations.hpp:367)
==4966==    by 0x109A26B: System::copyFile(std::string const&, std::string const&) (system.cpp:78)

Where System::copyFile(string,string) is a class from my system, which basically calls the above code.

I'm using Ubuntu 12.04 amd64 with boost 1.52 compiled by myself. I'm also using jemalloc as memory allocator.

Change History (2)

comment:1 Changed 6 years ago by anonymous

Summary: Possibly memory leak in filesystem::copy()Possible memory leak in filesystem::copy()

comment:2 Changed 9 months ago by anonymous

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.

Note: See TracTickets for help on using tickets.