Advertisement

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

Started by January 20, 2018 06:42 PM
5 comments, last by WitchLord 6 years, 10 months ago

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?

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.

 

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

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.

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

 

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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!

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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement