Boost logo

Boost :

Subject: Re: [boost] [locale] Memory leaks?
From: Jookia (166291_at_[hidden])
Date: 2013-03-07 15:41:43


Ah. I understand now. Thanks for explaining!

On 08/03/13 07:39, Artyom Beilis wrote:
> Jookia,
>
> I don't think this is a problem at all. Reachable code
> is not a memory leak. The data is eventually got destroyed,
> also note that we as users do not really have control
> of how lib deallocates resources.
>
> For example this code is perfectly fine code:
>
> #include <locale>
> #include <iostream>
>
> struct fct : public std::locale::facet {
> static std::locale::id id;
> fct(size_t n = 0) : std::locale::facet(n) {
> x=new int(1);
> }
> virtual ~fct() { delete x; }
> int *x;
> };
>
> std::locale::id fct::id;
>
> int main()
> {
> std::locale l(std::locale(),new fct(0));
> std::locale::global(l);
> std::cout.imbue(l);
> }
>
>
> But valgrind reports reachable code...
>
> There is nothing you can do.
>
> Artyom Beilis
> --------------
> CppCMS - C++ Web Framework: http://cppcms.com/
> CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/


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