I did read that an interpretered Lua (not LuaJIT) compiles and execute line by line (step by step) the code.
However, are compiled fragments of code stored in RAM? Or does Lua compile same line again and again?
If I declaired a local function before “init” function, and this local function was used in first frame in “update”, does this function compiled again and again every frame? Or the system stores this function as a binary in RAM and uses it?
And second question. About garbage collector. I did read, that it’s possible to switch it in the manual mode in another Lua apps. So, is it possible to use a manual gabage collector in Defold?
For example, the gabage collector can be launched then game menu is opened, a mission is complete etc.
2 Likes
I made game object “system”, and added the script, where in “update” function the gabarge collector forcely collects everything and stop itself after it (every frame). Performance became absolutly smooth! Thanx!
I didn’t ubderstand before that every function with arguments makes garbage table. But real-time games needs “go.set_position()”, “go.set_rotation()” every frame. So, I guess it is better, to collect in every frame explicitly.