Jump to content
  • Advertisement
Sign in to follow this  
olberg

boost::shared_ptr and stack overflow

This topic is 3992 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I converted my program to use boost::shared_ptr instead of normal pointers. I have class with std::vector with shared pointers in it and when I clear the vector I got crash with stack overflow and access violation in the vector. This is my first time using shared pointers in a complex program so it's probably caused by my bad design. I have something like this:
class MyClass
{
    // something
    vector<shared_ptr<AnotherClass>> my_vector;
};

class SecondClass
{
    // something else
    vector<shared_ptr<AnotherClass>> another_vector; // may have same elements with my_vector
};
Is this OK? Or how should I use shared pointers? And if anybody has a good guess what's causing the stack overflow, let me know.

Share this post


Link to post
Share on other sites
Advertisement
A stack overflow frequently indicates infinite recursion. Look at the call stack. Does the AnotherClass destructor affect the vectors in MyClass or SecondClass?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!