lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


If I start Lua program in my "restricted RAM" STM32 application, I now
recognized that if the Lua source file is increasing, the "startup
alloc block size" for luaL_loadfile will also increase.

... even if only the "static file size" increases (not adding more variables).

... e. g. if I increase the Lua text file increase from 12kB to 13kB,
the maximum memory alloc block size by Lua on startup by luaL_loadfile
will increase from 0x1000 (4kB) to 0x2000 (8kB).

Is there some estimation formula, how this "max memory block size"
required by Lua will depend on the lua code size?

Side Info / description of my system:
I am working in a "restricted RAM" system and try to keep with ca.
60kB/80kB RAM size ... therefore I thought it is a good idea to
restrict the maximum memory allocation amount to 8000 bytes, but now I
got an error as 0x2000 is larger than 8000 ... no general problem to
increase to 10000 or even 0x4000 ... just I would like to get some
estimation, how this "startup alloc" requirement depends on the Lua
file size... .

I am generally a bit surprised that Lua memory alloc requirement will
increase just by increasing "static Lua file size" ... or is it
required for Lua, that the complete "pre-compiled RAM" code is loaded
into RAM?

(would the alloc block loading on startup be smaller, if we load Lua
with the compiled Lua code instead of ASCII txt file? (in STM32 code
such ROM code in Flash memory generally is accessed very efficiently -
the CPU does not really make a difference accessing ROM or RAM - in
ARM the access code is also identical, just different addresses of
course ... and of course ROM cannot be written / changed ... (this
then would run into a memory exception error)).