Re: [Boost-bugs] [Boost C++ Libraries] #9181: memory leak in Date_Time

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9181: memory leak in Date_Time
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-19 22:41:43


#9181: memory leak in Date_Time
-------------------------------+-----------------------------------
  Reporter: gregory@… | Owner: az_sw_dude
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: date_time
   Version: Boost 1.48.0 | Severity: Problem
Resolution: | Keywords: Date_Time memory leak
-------------------------------+-----------------------------------
Changes (by Georg Sauthoff <mail@…>):

 * cc: mail@… (added)

Comment:

 I've reproduced your valgrind output on Fedora 19 (boost 1.53, gcc 4.8.2).

 The source seems to be

 /usr/include/boost/date_time/gregorian/gregorian_io.hpp:62

 {{{
 custom_date_facet* f = new custom_date_facet();
 }}}

 and

 /usr/include/boost/date_time/posix_time/posix_time_io.hpp:59

 {{{
 custom_ptime_facet* f = new custom_ptime_facet();
 }}}

 inside a {{{operator<<()}}} definition.

 But this memory leak is constant, i.e. it does not grow with the number of
 output operator calls - because it is guarded by:

 {{{
 if (std::has_facet<custom_ptime_facet>(os.getloc()))
 {
  // use allocated facet
 } else {
  // allocate facet
 }
 }}}

 The else branch has a comment that reads:

 {{{
 //instantiate a custom facet for dealing with times since the user
 //has not put one in the stream so far. This is for efficiency
 //since we would always need to reconstruct for every time period
 //if the locale did not already exist. Of course this will be overridden
 //if the user imbues as some later point.
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9181#comment:1>
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:15 UTC