|
Boost Users : |
Subject: Re: [Boost-users] memory leak when using shared_from_this
From: jochemspek (spam_at_[hidden])
Date: 2011-01-12 11:35:37
sorry - i found it in the documentation. I thought the problem was in
creating the pointer, but it was in the cyclic nature of the parent/child
relationship. for reference, it's in the docs on shared_ptr at
http://www.boost.org/doc/libs/1_45_0/libs/smart_ptr/shared_ptr.htm
"Because the implementation uses reference counting, cycles of shared_ptr
instances will not be reclaimed. For example, if main() holds a shared_ptr
to A, which directly or indirectly holds a shared_ptr back to A, A's use
count will be 2. Destruction of the original shared_ptr will leave A
dangling with a use count of 1. Use weak_ptr to 'break cycles.'"
-- View this message in context: http://boost.2283326.n4.nabble.com/memory-leak-when-using-shared-from-this-tp3214313p3214349.html Sent from the Boost - Users mailing list archive at Nabble.com.
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