Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-12-15 00:40:32


INsideR wrote:

> I have wrote simple programm:
> using namespace boost;
> shared_ptr<int> a(new int(10));
> shared_ptr<int> b;
> b=a;
> a.reset(new int(20));
> std::cout<<"a=="<<*a<<" b=="<<*b;
> return 0;
>
> Checking this programm with DevPartner BoundsChecker, i found memory
> leak:
> Type Quantity Total (bytes) Allocation Location Sequence
> Leak exiting program 1 84 setlocale - [setlocal.c, line 547
> (Boostt.exe)] 9 Memory Leak Exiting Program: Address 0x00E44F88 (84)
> allocated by _malloc_dbg.
>
> <if ( (ptloci = _malloc_crt( sizeof(threadlocinfo) )) == NULL )>
>
> Where is the problem? May be i write incorrect code?

Looks like your iostream implementation is allocating memory and does not
free it. Or your memory checker is buggy. Or both ;-)

I suspect that if you remove all lines which create/modify shared_ptr
instances, the leak will be still there.

- Volodya

>
>
>
> Best Wishes,
> Yury mailto:insider83_at_[hidden]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net