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
Wojciech Baczyński edited this page Jan 23, 2017
·
6 revisions
Useful Commands
file.remove("init.lua")
node.compile("info.lua")
require("basic") == dofile("basic.lc")
package.loaded['filename']=nil | only with require()
collectgarbage()
Useful codes
Volatile Module templates
local M, module = {}, ...
...
function M.init(csocket)
package.loaded[module]=nil
...
end
...
return M
Using: require("connector").init(c)
local module = _ -- this is a situation where using an upvalue is essential!
return function (csocket)
package.loaded[module]=nil
module = nil
...
end
Using: require("connector")(c)
Memory cleanup
Load some functions and at the end call init() !!! Otherwise our volatile modules won't work.
Additionally there is a little improvement while assigning tmp to some function and then reassign it to nil.