Jump to content
  • Advertisement
Sign in to follow this  
howie_007

Installed 2.32.0 and now getting Assertion `stringCache.size() == 0

Recommended Posts

angelscript/add_on/scriptstdstring/scriptstdstring.cpp:39: virtual CStdStringFactory::~CStdStringFactory(): Assertion `stringCache.size() == 0' failed.

The above error happens when I quit out my application. I'm developing on Linux. I'm not sure why the stringCache still has strings in it. Shouldn't the destructor just clean-up the left over strings instead of asserting?

Share this post


Link to post
Share on other sites
Advertisement

Make sure to shutdown the script engine before you exit main so it will have a chance to free up the memory and release any string constants that were allocated during the script compilations.

 

Share this post


Link to post
Share on other sites

That did not work. I have the script engine in a singleton so that as my script components come in and out of existence, they can draw from and return to the context pool in the singleton. My design assumes the context can be freed regardless of if the script engine has freed itself. When the game exits, the script components that are still around, they just free the contexts they are currently holding.

Share this post


Link to post
Share on other sites

The problem is that the static CStdStringFactory stringFactory in the scriptstdstring add-on is being destroyed before your singleton that holds the engine instance. 

 

Share this post


Link to post
Share on other sites

Yeah, that's what I thought. I'll just comment out the assert since it's just a map holding an std::string and an int which is all self cleaning. Thanks for your help!

Edited by howie_007

Share this post


Link to post
Share on other sites

Doing just that would lead to the script engine attempting to release the string constants after the string factory has been destroyed. This in turn might lead to a crash in your application.

 

I've made a change in the string add-on so that the string factory is now allocated dynamically, and only deleted if the string cache is empty. This means that there will be a memory leak if the singletons are not deleted in the right order, but at least there is no risk of crashes. 

The leak is only upon application shutdown so you won't have any impact on this except if you run your application with any memory leak finding tool.

 

You can get this change from the SVN revision 2464.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
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!