Boost logo

Boost :

Subject: Re: [boost] [locale] Memory leaks?
From: Artyom Beilis (artyomtnk_at_[hidden])
Date: 2013-03-07 08:02:53


You had mistaken "reachable" code with memory leaks... Especially if some std::locale::global remains etc. It is not a bug nor even a problem.   Artyom Beilis -------------- CppCMS - C++ Web Framework:   http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: Jookia <166291_at_[hidden]> >To: boost_at_[hidden] >Sent: Sunday, March 3, 2013 10:19 PM >Subject: [boost] [locale] Memory leaks? > >Hello! > >I've been debugging my application that uses Boost.Locale for the past five hours or so, and I've found it curious that it leaks memory. > >In order to stop it, I have to do a couple of weird things, such as including ICU in to my projects and calling u_cleanup at the end of my application. I also have to disable certain facets. I've put all this together in some source code, that by default won't leak, but uncommenting various parts will cause it to leak: > >// ----  BEGIN CODE ---------------------------------------------------- > >#include <boost/locale.hpp> >#include <unicode/uclean.h> >#include <iostream> > >using namespace boost::locale; >using namespace std; > >int main() >{ >  generator gen; >  gen.categories( >    convert_facet    | >    //collation_facet  | // Various errors. >    //formatting_facet  | // Various errors. >    //parsing_facet    | // Various errors. >    message_facet    | >    //codepage_facet    | // Various errors. >    boundary_facet    | >    calendar_facet    | >    information_facet); > >  locale newLoc = gen("zh_CN.GB18030"); > >  locale::global(newLoc); >  cout.imbue(newLoc); > >  // ios_info::get doesn't clean up after itself. >  //cout << as::date << time(0) << endl; > >  // Do this at the end of the program to clean up resources. >  locale::global(std::locale("C")); >  cout.imbue(std::locale("C")); >  u_cleanup(); >} > >// ----  END CODE ------------------------------------------------------ > >Dumping this as 'hello.cpp' and running this is how I'm debugging it: > >g++ hello.cpp -lboost_locale -licuuc && valgrind --leak-check=full --show-reachable=yes ./a.out > >Thanks, >Jookia. > >_______________________________________________ >Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost > > >


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