You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a few months ago, there was an context leak with coroutine lib yuin/gopher-lua#438, which I have already fixed and been merged yuin/gopher-lua@8ee9c41. Base of my observation the memory will be freed at some point of time.
@deflinhec yes, this is specific to yuin/gopher-lua and partly to nakama and how it is using this lib. We could maybe close this but it would be than nice to extend lua docs and add best pratices when it comes to developing in sad runtime on what to take extra care. Like here for memory releasing time as it could impact session lenght/number of matches performed until "used" memory has been released.
@AleksandarEri
When the do ... end block ends, the local variables a and b go out of scope.
Since a and b are local, their names are no longer accessible. However:
The table that a referred to is still referenced by d['a'].
The value 1 is primitive and is still stored in d['b'].
Lua's garbage collector works by reference counting. As long as there is a reference to an object, it will not be garbage collected.
set d['a'] = nil d['b'] = nil for requested result
Description
Using locally scoped variables in lua runtime are not being released correctly, thus memory of table keeps increasing overtime.
Provided Code
`local d = {}
do
local a = {}
local b = 1
d['a'] = a
d['b'] = b
end
for k, v in pairs(d) do
print(k, v)
end
collectgarbage()
print("=====================")
for k, v in pairs(d) do
print(k, v)
end`
Steps to Reproduce
Expected Result
Inner locally scoped variables are released as soon as they are no longer used and memory is retained correctly.
Actual Result
Memory persists and inner locally scoped variables are kept.
Context
Your Environment
The text was updated successfully, but these errors were encountered: