Background task that prints Lua and bitmap RAM every few seconds.
This is a very simple script that can be run as a background task on your model config.
It is useful within the simulator when tracking memory usage of your script.
Install: copy the folder to SCRIPTS:/memstatus/ on the radio (or the simulator's scripts/ folder) and restart.
-- Simple script that can run as a background task.-- it will print out memory status to the console every -- 5 seconds (or whatever interval you set)-- this is helpfull when building memory sensitive scripts-- as it can aid tracking down memory intensive code.localconfig={}config.taskName="MemStatus"config.taskKey="memstat"localinterval=5localwakeupScheduler=os.clock()localmemprevluaRamAvailable=0prevluaBitmapsRamAvailable=0functionwakeup()localnow=os.clock()if(now-wakeupScheduler)>=intervalthenwakeupScheduler=nowmem=system.getMemoryUsage()localramDiff=(mem.luaRamAvailable-prevluaRamAvailable)/1000..'kB'localbmpDiff=(mem.luaBitmapsRamAvailable-prevluaBitmapsRamAvailable)/1000..'kB'prevluaRamAvailable=mem.luaRamAvailableprevluaBitmapsRamAvailable=mem.luaBitmapsRamAvailableprint("-------------------------------------------------------")print("luaRamAvailable..........: "..mem.luaRamAvailable/1000.."kB".." ["..ramDiff.."]")print("luaBitmapsRamAvailable...: "..mem.luaBitmapsRamAvailable/1000.."kB".." ["..bmpDiff.."]")print("------------------------------------------------------\r\n")endendlocalfunctioninit()system.registerTask({name=config.taskName,key=config.taskKey,wakeup=wakeup})endreturn{init=init}