How do I know who holds the shared_ptr<>?

boost, c++, memory-leaks, shared-ptr

Solution

You can't know, by only looking at a `shared_ptr`, where the "sibling pointers" are. You can test if one is `unique()` or get the `use_count()`, among other methods.

Problem

I use `boost::shared_ptr` in my application in C++. The memory problem is really serious, and the application takes large amount of memory. However, because I put every newed object into a `shared_ptr`, when the application exits, no memory leaking can be detected. There must be something like `std::vector<shared_ptr<> >` pool holding the resource. How can I know who holds the `shared_ptr`, when debugging? It is hard to review code line by line. Too much code...

Original source

Related problems