Garbage Collection - Lua

Hello everyone,
I was wondering how garbage collection is handled in Lua modules?
Can we/ do we need to use setmetatable on table and mark which are weak tables and which are strong or by default there are no garbage collection at all?
Or does variables gets destroyed as soon function execution is finished?
Is there a way to use standard lua collectgarbage call or do we need to use something else :slight_smile:
Thanks.

Hello, @Eatos!

Regarding the Lua Runtime, Nakama uses GopherLua which you can get more info/details on here: GitHub - yuin/gopher-lua: GopherLua: VM and compiler for Lua in Go

Regarding Lua modules on Nakama, nothing scoped within the Lua function should survive beyond the execution scope of that function, and Heroic strongly advises against using global variables/state within any of your functions. Therefore, it should never be a need to manually call collectgarbage() yourself.

Hope to have helped.

Cheers!

1 Like