system.getMemoryUsage¶
since 1.1.0
Return Ethos Memory Usage.
Parameters¶
None.
Returns¶
Table with elements:
mainStackAvailable(integer) Memory available for the main stack (bytes)ramAvailable(integer) Memory available for the whole system (bytes)luaRamAvailable(integer) Memory available for Lua scripts execution (bytes)luaBitmapsRamAvailable(integer) Memory available for loading bitmaps in Lua scripts (bytes)
Examples¶
local mem = system.getMemoryUsage and system.getMemoryUsage() or {}
print(string.format("lua free %.1fkB, bitmaps free %.1fkB, stack free %.1fkB",
(mem.luaRamAvailable or 0) / 1024,
(mem.luaBitmapsRamAvailable or 0) / 1024,
(mem.mainStackAvailable or 0) / 1024))
On current radios the Lua heap and bitmap memory come from one shared region, so treat the two numbers as one budget. Track the minimum stack seen, not single readings. See the memory monitor recipe and Saving RAM.
Used in¶
Real-world usage¶
Called 10 times across 3 open-source Ethos Lua projects. A few short excerpts: