
29 Oct
2007
29 Oct
'07
1:29 p.m.
zzp good wrote:
hi, guys, I found memory leak using the following code:
#include
#include using namespace boost; class C { public: shared_ptr<C> pNext; };
void test() { shared_ptr<C> c0(new C()); shared_ptr<C> c1(new C()); c0 -> pNext = c1; c1 -> pNext = c0; }
void main() { test();
_CrtDumpMemoryLeaks(); }
See http://www.boost.org/libs/smart_ptr/weak_ptr.htm. It's specifically designed to break these sorts of ownership cycles. Jeff Flinn