Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-02-17 10:01:48


On Fri, 17 Feb 2006 15:44:14 +0200, Alo Sarv wrote
> On 2/17/06, Bart <bartmann.nsd_at_[hidden]> wrote:
> > Could you please provide more information about your testing methods.
> >
> > Did you try this test with other objects besides ptime? What about other
> > non-date_time objects?
>
> Yes. Tested time_duration, date, date_duration and date_period
> operator<<, and they did not show any memory leakage. For testing, I
> compiled/ran the test application, and watched the memory usage in
> Windows Task Manager. No other user-defined or Boost types show this
> leakage, so as far as I can tell, this leakage is limited to ptime
> operator<<.

Well, that's odd. The only place that date-time does an allocation is in
operator<< and operator>>. So there 'could' be a problem with leaking in that
code -- either a bug in date-time code or standard library code. However,
time_duration and posix_time use the exact same allocation techniques (and
facet code) so should exhibit the exact same leaking behavior. Basically,
what gets allocated is a custom date-time facet that gets imbued into the
stream. This gets done on the first call to operator>> or operator<< on a
particular stream. After that it just uses the facet avoiding the allocation.
 The facet is written to work with C++ I/O streams which has a reference
counting and should destroy the facet when the stream is destroyed. In the
case of std::cout this may be after main has exited.

If you want to trace it thru you could explicitly create and delete a
stringstream and check it's behavior. The date-time code that does the
allocations is in date_time/posix_time/posix_time_io.hpp.

Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk