How to Reset the Lua Environment?
Posted: Sun Jul 06, 2025 3:19 pm
Hello!
I’m using Dialogue System, and I’ve noticed that after exiting and loading a saved game, many unrelated assets remain loaded in memory. These include Texture, SpriteAtlas, DialogueDatabase instances, etc. After some investigation, I found that even after exiting the saved game and unloading the scene, some static dictionaries in the Lua environment are still holding references to these objects.
I tried calling methods similar to InitStaticVariables in the LuaInterpreter and Lua classes during unloading. As a result, those assets were no longer referenced and could be unloaded properly. (Calling DatabaseManager.Clear alone did not have this effect.)
Did I miss anything? If calling methods like InitStaticVariables is the correct approach, could you consider adding some similar public methods? Thank you!
I’m using Dialogue System, and I’ve noticed that after exiting and loading a saved game, many unrelated assets remain loaded in memory. These include Texture, SpriteAtlas, DialogueDatabase instances, etc. After some investigation, I found that even after exiting the saved game and unloading the scene, some static dictionaries in the Lua environment are still holding references to these objects.
I tried calling methods similar to InitStaticVariables in the LuaInterpreter and Lua classes during unloading. As a result, those assets were no longer referenced and could be unloaded properly. (Calling DatabaseManager.Clear alone did not have this effect.)
Did I miss anything? If calling methods like InitStaticVariables is the correct approach, could you consider adding some similar public methods? Thank you!