Opened 10 years ago
Closed 9 years ago
#7156 closed Bugs (fixed)
interprocess buffer streams leak memory on construction
Reported by: | Owned by: | Ion Gaztañaga | |
---|---|---|---|
Milestone: | To Be Determined | Component: | interprocess |
Version: | Boost 1.44.0 | Severity: | Problem |
Keywords: | Cc: |
Description
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:
basic_ios_t::init(&m_buf);
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.
Attachments (2)
Change History (6)
by , 10 years ago
Attachment: | bufferstream_leak.cpp added |
---|
comment:1 by , 10 years ago
The same leak appears in vectorstream family of classes, too. Tested with Boost 1.51.
comment:2 by , 9 years ago
We are also facing this issue. please fix this in the official boost release.
comment:3 by , 9 years ago
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 http://accu.org/index.php/journals/264 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.
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.