My logger on an ESP8266 running NodeMCU builds a CSV block by doing buf = buf .. line .. "\n" inside a loop. With a few hundred lines it is fine, but with several thousand it gets very slow and I sometimes run out of memory, even though the final string is not that big.
I have read that table.concat should be used instead. Why is repeated concatenation so expensive in Lua, and what is the recommended pattern on a device with little RAM?




