Collect garbage after every call

This commit is contained in:
Maurice Heumann 2021-05-01 15:13:03 +02:00
parent 56c522274c
commit 49bc9f0326
2 changed files with 9 additions and 2 deletions

View File

@ -301,7 +301,7 @@ namespace scripting::lua
context::~context()
{
this->state_.collect_garbage();
this->collect_garbage();
this->scheduler_.clear();
this->event_handler_.clear();
this->state_ = {};
@ -310,12 +310,18 @@ namespace scripting::lua
void context::run_frame()
{
this->scheduler_.run_frame();
this->state_.collect_garbage();
this->collect_garbage();
}
void context::notify(const event& e)
{
this->event_handler_.dispatch(e);
this->collect_garbage();
}
void context::collect_garbage()
{
this->state_.collect_garbage();
}
void context::load_script(const std::string& script)

View File

@ -30,6 +30,7 @@ namespace scripting::lua
void run_frame();
void notify(const event& e);
void collect_garbage();
private:
sol::state state_{};