
Hi, I have a somewhat peculiar problem concerning the shared_ptr template. I use an STL container to hold several shared_ptr values. When the container is destroyed, all the destructors are called correctly, but the memory is not freed. Furthermore, shared_ptr usage introduces a 100x memory overhead (or more) in my case. Compiler system is GCC. Consider the following short example: #include <iostream> #include <string> #include <deque> #include <boost/shared_ptr.hpp> class A { public: int a; int b; }; int main() { std::string tmp; std::cout << "Enter something to continue" << std::endl; std::cin >> tmp; { std::deque<boost::shared_ptr<A> > list; for (int i = 0; i < 10; i++) { boost::shared_ptr<A> ptr(new A()); list.push_back(ptr); } std::cout << "Enter something to continue" << std::endl; std::cin >> tmp; } std::cout << "Enter something to continue" << std::endl; std::cin >> tmp; } Between the first and the second stop, the program size in memory grows by about 150k... and that's for 10 objects which are <20 bytes large, individually. And to top it off, it leaks memory. Between stops two and three the memory *should* be freed since the scope is left. I can include a destructor doing debug output in the class which shows that the objects are indeed destroyed. But the memory stays allocated. I suspect this is a GCC problem, but I have actually no clue... I tested it on a recent Debian "Unstable" and an Ubuntu "Breezy". GCC versions varying from 3.2 to 4.1. Or do I use the template in a wrong way? Suggestions would be very welcome... and if this is a known bug in GCC, a feasible work-around would be great. Thanks in advance, Robert