Boost Users :
Subject: Re: [Boost-users] memory lost using cyclic pointers (shared_ptr)
From: Igor R (boost.lists_at_[hidden])
Date: 2011-09-09 02:44:08
> I think that it is expected that shared_ptr cannot handle points that
> have cyclic references. In the following example, "a" points to "b"
> and "b" points to "a". There is a memory leak. I then modified it to
> remove the dependence using bare pointers, then the leak is resolved.
> But this is not a very satisfactory solution, as the programmer has to
> know whether to use bare point or shared_ptr. For very complexity
> program, it may not be possible to figure out it correctly.
> Does anybody know what is the best strategy for handing cyclic pointers?
On of the directions should use weak_ptr.
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