Subject: [Boost-bugs] [Boost C++ Libraries] #7379: Boost Format strings causing memory leaks
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-09-14 16:19:41
#7379: Boost Format strings causing memory leaks
----------------------------------------------------+-----------------------
Reporter: Jason Vincent <jason.vincent@â¦> | Owner: samuel_krempp
Type: Bugs | Status: new
Milestone: To Be Determined | Component: format
Version: Boost 1.44.0 | Severity: Problem
Keywords: format memory leak |
----------------------------------------------------+-----------------------
I determined that certain format string used in a boost::wformat object
will leak memory. I was using a formatter to convert a value to a
floating point value with and without a percent symbol at the end.
The two format strings I was using were:
{{{
L"%1$.1f"
}}}
- format with one decimal place of precision[[BR]]
{{{
L"%1$.0f %%"
}}}
- format with no decimal places but add a percent sign
I determined that removing the "%%" reduced some of the memory leaks, and
removing the "$.1f" or "$.0f" eliminated the remaining memory leaks.
This was done using Boost v 1.44 with Visual Studio 2010 on Win 7 64-bit.
For more context here is part of the code that I can share:
note, mFormatter is a boost::wformat member object
{{{
MyObject::MyObject() :
mNumDecimalPlaces (1),
mFormatter (L"%1$.1f") //--- THIS LEAKED
{
}
std::wstring MyObject::PercentToString(const FLOAT iMin,
const FLOAT iMax,
const FLOAT iPercent)
{
FLOAT value = PercentToValue(iMin, iMax, iPercent);
return boost::str(mFormatter % value); //--- THIS LEAKED
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7379> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC