I stumbled across a problem where I am able to save my code onto the flash memory of an ESP8266 successfully, but as soon as it starts I get a "not enough memory" error.
The code itself doesn't create a lot of objects. It appears to me as if the code size per se is the problem. So I was wondering if the complete code would actually be loaded into the RAM in plain text during the execution.
I also tried the compile & upload button in my Esplorer, which didn't seem to change much.
By how much does compiling Lua actually reduce the code size? I would have thought that at least all the white space overhead would be gone.
Yes, script is loaded in ram before being executed.
It takes more ram if Lua source is plain text, as Lua VM will have to compile it into bytecode. In general, you can precompile Lua source outside of target Lua VM, see http://www.eluaproject.net/doc/v0.8/en_using.html, section "Cross-compiling your eLua programs"
And you will want to compile with debug info stripped out. See -s
option of luac
.