# 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 on other sites

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 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 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 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 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.

## Create an account

Register a new account

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
13
5. 5

• 12
• 9
• 9
• 17
• 21
• ### Forum Statistics

• Total Topics
632601
• Total Posts
3007344

×