Boost logo

Boost :

Subject: Re: [boost] [date_time] memory leak?
From: Artyom (artyomtnk_at_[hidden])
Date: 2010-03-18 09:05:06


Hello, > > #include <iostream> > #include <boost/date_time/posix_time/posix_time.hpp> > > int main() > { >     std::cout << > boost::posix_time::microsec_clock::local_time() << > std::endl; >     return 0; > } > Generally boost::posix_time imbues its own facet into the locale std::cout steam. So this facet remains reachable because AFAIK std::cout is not destroyed at all. So if you do: std::cout.imbue(std::locale::classic()); Before return, no "leaks" would be at all. Same as if you would write to any destroyable stream like std::ostringstream; std::ostringstream tmp; tmp << boost::posix_time::microsec_clock::local_time(); std::cout << tmp.str() << std::endl; So it is rather C++ design question why std::cout does not destroy its own locale. Artyom


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